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

Menu displays hidden pages


3 Posts   1452 Views


10 May 2010 at 7:22pm Community Member, 131 Posts

My site has a navigation menu with submenu items and some of them should be hidden.

Code for the menu:

<ul id="navigation">
   <% control Menu(1) %>   
      <li><a href="$Link" title="Gehen Sie zur $Title.XML Seite" class="$LinkingMode"><span>$MenuTitle.XML</span></a>
         <% if AllChildren %><ul class="subnavigation"> <% end_if %>
         <% control AllChildren %>
            <li><a href="$Link" title="Gehen Sie zur $Title.XML Seite" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
         <% end_control %>
         <% if AllChildren %></ul> <% end_if %>
   <% end_control %>

Unfortunately this seems to display all sub-pages even if they are unchecked at 'Show in Menu'.

For example: There is a Products page and it has 19 child-pages but only 4 should be displayed. How can I hide the 15 pages? And I don't want to put them underneath another page - that would be pretty messy.

My question: How can I have child-pages that stay hidden in the menu?


10 May 2010 at 10:05pm Forum Moderator, 5511 Posts

AllChildren returns ALL the children, regardless of whether they are visible or not. Using the standard <% control Children %> filters the pages by the show in menus checkbox.


11 May 2010 at 3:44am Community Member, 131 Posts

:-) Thanks! Didn't know that there is also a Children control.