Jump to:

23001 Posts in 11702 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Menu displays hidden pages

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: 1355 Views
  • suntrop
    Avatar
    Community Member
    131 Posts

    Menu displays hidden pages Link to this post

    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 %>
          </li>
       <% end_control %>
    </ul>

    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?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Menu displays hidden pages Link to this post

    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.

  • suntrop
    Avatar
    Community Member
    131 Posts

    Re: Menu displays hidden pages Link to this post

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

    Bey
    suntrop

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