Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Accessing private page link for logged out users.


Reply


7 Posts   1763 Views

Avatar
dancrew32

Community Member, 15 Posts

6 March 2009 at 1:20pm

There's this 2nd level link on one of our sites where we had a page with "access->Who can view this page?" set to "logged in users."

The link for that page used to be displayed for users that were NOT logged in, so that when they clicked on it, it would take them to the login page, then to the page that they were trying to get to.

When I upgraded to the latest stable silverstripe (from the previous stable version), the link to that page doesn't show to users that are logged out. How would I make the link show for users that are logged out so that the process would be the same as it previously was?

I know I could write in the link manually, but I need a way to do it through the cms, as people that don't know html are maintaining the site.

Thanks for any help anyone can provide.

Avatar
TerryMiddleton

Community Member, 108 Posts

30 April 2009 at 3:34pm

I have a need to do the same thing.

I need to show the link to the page but if they are not logged in, they get a login/registration form and then they can see the content.

I'm going to subscribe to this tread in hopes we both find the answer.

Terry

Avatar
camfindlay

Forum Moderator, 188 Posts

4 September 2009 at 10:23pm

that's a plus 1 for me too... I would also not just like the menu item but also the ability to show parts of a secure page within a holder page but have the actual page locked down and redirect to a registration form or other page if they try to access.

Any point in the right direction would be great :) thanks.

Avatar
zenmonkey

Community Member, 532 Posts

5 September 2009 at 11:04am

What about creating a custom page function like

function GetPrivatePage(){
return DataObject::get("SiteTree", "ShowInMenus = 1 AND CanViewType = 'LoggedInUsers'");
}


That way your could render the Data from in that Page in a control

Just a thought, maybe too simple and who knows what the potential security consequences are.

Avatar
camfindlay

Forum Moderator, 188 Posts

5 September 2009 at 12:16pm

thanks I will give that a try and post my results

Avatar
camfindlay

Forum Moderator, 188 Posts

7 September 2009 at 11:53am

Would this function go in my ArticleHolder or ArticleHolder_Controller class?

Rendering with a control in the template would be

<% control GetPrivatePage %>
<a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a>
<% end_control %>

in my ArticleHolder.ss?

Am I approaching this right?

thanks in advance for your help :)

Avatar
camfindlay

Forum Moderator, 188 Posts

7 September 2009 at 12:13pm

Turns out that the AllChildren method does actually work and show Children pages even if they are locked down with Security... I had my holder page behavior set wrong lol

Still a good thing to know...