Setting Permissions on External Page Links in AutoNav

Permalink 1 user found helpful
Hi all,

I have a relatively simple question --

When a visitor browses to the site I'm working on, they should see only one page in the navigation (the homepage).

Once they register, and are approved, they can log in and see several other pages in the navigation.

The problem I'm having is that, though I can set permissions for this on pages that actually exist in my Concrete5 site, I can't seem to figure out a way to set permissions for links to external pages I've created in the autonav as well. Essentially, the external links ALWAYS show up, whether you're logged in or not. I want them to show up only when logged in.

HALP! Any suggestions?
Thanks

 
Dflow replied on at Permalink Reply
BUMP!

Same issue here.
Shotster replied on at Permalink Reply
Shotster
I could be wrong on this, but I don't think you can set permissions on external links. That said, if all you want to do is hide stuff from people who aren't logged in, then you can easily check to see if the current user is logged in and then conditionally display or not display the stuff.

if (User::isLoggedIn()) {
   // show external links
} else {
   // regular site visitor, so don't show external links
}

Obviously, you need to delve into code to do this. I can't currently think of a way to do this via the UI.

-Steve
jordanlev replied on at Permalink Reply
jordanlev
Shotster is right, and to further clarify -- you want to create a custom template for the autonav block and put his code in there.
benradler replied on at Permalink Reply
I went with this route, much like shotster recommended:

if (User::isLoggedIn()) {
   // show external links
} else {
   // regular site visitor, so don't show external links
}


It would be really helpful in a future release to have permissions act the same way on external links as they do on internal C5 pages. Very frustrating.
jordanlev replied on at Permalink Reply
jordanlev
I think the problem is that an external link lives outside of the C5 site, so C5 has no say over its actual permissions (someone can just go to that URL if they know it).
Note how the code sample doesn't actually check permissions on the external link, but rather just checks if they're logged in or not.

In other words, there's nowhere to even edit permissions for an external link in C5, because they're not actually pages stored in the system.

I understand that it can be frustrating to figure things out in a system so large and complex as Concrete5, though -- hopefully this forum thread will help others who run into the same problem in the future.
benradler replied on at Permalink Reply
Essentially what I was suggesting is that the C5 developers implement a feature that allows external links to display based on inherited permissions from C5 users and groups.

There's no reason there couldn't be a setting for permissions, say for Admins, Registered Users, and Guests to have the ability to see or not see external links based on the code that shotster and I used to hack around this issue (or whatever code is already in place to do this for internal C5 pages)
mibookscom replied on at Permalink Reply
i'd also like to be able to hide external links until user logs in.

where do i put the code??

many thanks
jordanlev replied on at Permalink Reply
jordanlev
Try using this instead:
http://www.concrete5.org/marketplace/addons/page-redirect...
(Please read the instructions on that page too -- it requires another free addon to be installed as well).

Instead of having an "External Link" in your sitemap, just create a normal page, and put the "redirect" attribute on it. Now you have a real C5 page you can set permissions on, hide from nav, etc.
mibookscom replied on at Permalink Reply
thanks for the advice,
what im actually trying to acheieve is to hide two system pages - members and profile from guests, then display to registered users after login.
The permissions seem to be over-ridden by "canonical url" thingy stating that these pages must be available from at least one url..
any ideas?
jordanlev replied on at Permalink Reply
jordanlev
You should definitely be able to set permissions on those.
Also, I think there's some setting in the dashboard somewhere for making profile pages public or not, so you may want to look at that as well.
mibookscom replied on at Permalink Reply
yes i have set the permissions for those two pages to be hidden from guests yet they still show up!
thats why i was trying to have them as external links in the nav then hide those links from the nav.. if that makes sense..?
jordanlev replied on at Permalink Reply
jordanlev
Weird. Sorry, I have no idea. External links definitely won't help though because those pages are internal to your site. You could add an external link but the internal pages are still there (so adding an external link is just making a second link to it, not replacing the one already there).
PatrickHenry replied on at Permalink Reply
PatrickHenry
Here's a use case:
Large writer/editor/publisher work group scenario.
Content Creators should have the ability to create an external URL via the site map.
Once created, properties should be available there for that url for them to add:
• Description
• Thumbnail
That's all that's needed. Because then, paired w/ the Page List block and a custom template that does thumbnails, you can treat the external URL as "page" displayed there in the page list.
Very useful for easy training for content creators.
This post almost has it:
http://www.concrete5.org/index.php?cID=39089&editmode=1...

That works perfect for admin, but for some reason, there are no Page Properties displayed for others, even when they create the external link AND it's inheriting it's parent pg. permissions, which have them able to access properties.
However, if I edit the permissions, via Page Search—which it has none for everything on btw—it works for said editors.
Any idea on how to inherit the correct permissions? Page Type default isn't a displayed option, for obvious reasons I guess.
But there's a few needed for externals: Properties, Permissions, Delete, Move
Any suggestions?
tabercreative replied on at Permalink Reply
tabercreative
Did you ever manage to get this working?

I run into this issue with nearly every site I do for clients. They always want to be able to edit properties and attributes on external links.
PatrickHenry replied on at Permalink Reply
PatrickHenry
It's a convoluted solution, but works.
I made a custom page type called "Exit", but you can call it whatever.
Then I edited it's default properties to include the thumbnail as active.
You can then train your editors to use Page Search if they need the additional properties on an external link. Find the external link using Page Search, then Edit—>Design and set it as an Exit Page Type. Once that's set, you can edit it's permissions and say to "Inherit from Page Type" and control it that way.
Wish it was simpler, but this works okay for us.
Hope that helps!
tabercreative replied on at Permalink Reply
tabercreative
Thanks for taking the time to explain your workaround!

Unfortunately for my clients, that is much too complicated. This is frustrating. I hope someone can come up with a more elegant solution.
PatrickHenry replied on at Permalink Reply
PatrickHenry
Sure thing!
I'm just paying my dues. Many before me were quick to answer my questions. I try to be a courteous to others as well—that's what I love about c5's community.
Option #2: Meta Tag Refresh
Quite a bit more elegant, but adds an extra web hop.
Instead of using an external link option, use a page and have them add the "Header Extra Content" attribute to it.
Then paste in this meta tag to be added into the page html <head>
<meta http-equiv="refresh" content="0;URL=http://www.enter.site/redirect/URL/here">

The 0 tells it to refresh automatically. Effectively making it a redirect while giving you description & Thumbnail options to boot.
BONUS POINTS: Any page type will work. But if you go ahead and make one as previously suggested, an "exit" page type, you can edit it's defaults, add in the meta tag, and all pages will have that set once chosen as the page type for the page. So you just have to tell your editors, "Choose X page type, then edit that Header Extra Content attribute and paste in the URL to redirect to. Double check to ensure it works. Done."
This will also allow you to make edits to "Exit" pages in the future if needed en masse, along w/ easy sorting for troubleshooting.
Looking back over the thread, looks like Jordan Lev linked up a way to do this via add-ons that would make it a smig nicer possibly.
Hope that helps!
goodnightfirefly replied on at Permalink Reply
goodnightfirefly
I've made a pull request for 5.7 which enables attributes and permissions from the regular sitemap: https://github.com/concrete5/concrete5-5.7.0/pull/2089...

If you are able to, test it out!