Jump to:

22999 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Page Accesss to Not Logged in viewers

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: 418 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    Page Accesss to Not Logged in viewers Link to this post

    Hi,

    in the 'access' tab it's really easy to set a page so it can only be access by logged in members, or specific groups. But i'm wanting a page to only be visible (and shown in the menus) when the user is logged out.

    Has anyone come across an easy solution for this?

  • novaweb
    Avatar
    Community Member
    109 Posts

    Re: Page Accesss to Not Logged in viewers Link to this post

    In Page.ss:

    <% if CurrentMember %>

    <p>A logged in person can see this</p>

    <% else %>

    <p>A logged out person can see this</p>

    <% end_if %>

    Have fun!
    Nova

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Page Accesss to Not Logged in viewers Link to this post

    that will work for the page content itself, assuming the page has it's own page type and tempalte, but i'm really looking at something that will remove the item from the menu...

  • novaweb
    Avatar
    Community Member
    109 Posts

    Re: Page Accesss to Not Logged in viewers Link to this post

    Yes you will need to either edit the existing Page.ss or create your own Page Type.

    In Navigation.ss:

    <% if CurrentMember %>
    <ul>
       <% control Menu(1) %>   
          <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
       <% end_control %>
    </ul>
    <% else %>
    <ul>
    <li><a href="">Viewable by Logged Out Link</a></li>
    </ul>
    <% end_if %>

    This can also be achieved other ways, I'm just trying to keep it simple.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Page Accesss to Not Logged in viewers Link to this post

    thanks... You're example would replace the whole menu, which is fine if this is what you need. in my case i just have a few pages. However, you've got me thinking, and I think i'll just need to add another tickbox to the behaviour tab, and then do something like this

    <ul>
    <% control Menu(1) %>
    <% if CurrentMember %>
    <% if DontShowToLoggedInMemebers %>
    <% else %>

    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>

    <% end_if %>
    <% else %>

    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>

    <% end_if %>
    <% end_control %>
    </ul>

    that should work! thanks

  • novaweb
    Avatar
    Community Member
    109 Posts

    Re: Page Accesss to Not Logged in viewers Link to this post

    Yeah was thinking something similar. Good luck!

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