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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Menu displays hidden pages


Go to End


3 Posts   2198 Views

Avatar
suntrop

Community Member, 141 Posts

10 May 2010 at 7:22pm

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?

Avatar
Willr

Forum Moderator, 5523 Posts

10 May 2010 at 10:05pm

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.

Avatar
suntrop

Community Member, 141 Posts

11 May 2010 at 3:44am

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

Bey
suntrop