Jump to:

22999 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Accessing private page link for logged out users.

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

Page: 1
Go to End
Author Topic: 1597 Views
  • dancrew32
    Avatar
    Community Member
    15 Posts

    Accessing private page link for logged out users. Link to this post

    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.

  • TerryMiddleton
    Avatar
    Community Member
    108 Posts

    Re: Accessing private page link for logged out users. Link to this post

    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

  • camfindlay
    Avatar
    Forum Moderator
    83 Posts

    Re: Accessing private page link for logged out users. Link to this post

    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.

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Accessing private page link for logged out users. Link to this post

    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.

  • camfindlay
    Avatar
    Forum Moderator
    83 Posts

    Re: Accessing private page link for logged out users. Link to this post

    thanks I will give that a try and post my results

  • camfindlay
    Avatar
    Forum Moderator
    83 Posts

    Re: Accessing private page link for logged out users. Link to this post

    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

  • camfindlay
    Avatar
    Forum Moderator
    83 Posts

    Re: Accessing private page link for logged out users. Link to this post

    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...

    1597 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.