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

Including non-viewable pages in menus


Reply


2 Posts   894 Views

Avatar
Johnny

Community Member, 34 Posts

30 October 2010 at 10:49am

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

Avatar
Willr

Forum Moderator, 5513 Posts

30 October 2010 at 12:36pm

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.