Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Including non-viewable pages in menus

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: 796 Views
  • Johnny
    Avatar
    Community Member
    34 Posts

    Including non-viewable pages in menus Link to this post

    Hi!

    I'm using <% Menu(level) %> to construct my menus. Some pages have restricted access, only logged users can access these.

    But, the thing is, I still want those "logged-in users only" pages to appear in menus (if the user is not logged, the login form appears then he can access it).

    Looking at the code, both "Children" and "Menu" methods filter those pages that can't be viewed. It may has some sense for some people, but for some others, everything an user "could" access should be included in menus (we don't want to hide what they can't reach).

    I've fixed this issue by making a patch to core/model/hierachy.php file, but maybe there's another way without messing with the Sapphire code.

    Thank you,

    JP

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Including non-viewable pages in menus Link to this post

    You can use <% control AllChildren %> to get all the children (regardless of permissions), not sure if you can do AllMenu, I assume not.

    Another way around it would make redirector pages to the hidden pages. Make the redirector pages public and in the top level menu. You will then have the problem of 2 links when they're logged in but another work around is to add a class (or hide) pages of type RedirectorPage when logged in.

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