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

Vertical Menu problem - want level 1 and level 2 to be visible


Go to End


2 Posts   1500 Views

Avatar
borriej

Community Member, 267 Posts

6 May 2010 at 8:49pm

Edited: 06/05/2010 9:00pm

Hello

I have a vertical menu with the level 1 pages displayed.
When you click on a page that has children it should display them.
See example.

So i thought this code should do the trick, but it doesn't do anything. I'm only seeing level 1.

In page.php I have enabled children.

   static $allowed_children = array('Page');

<ul>
 	<% control Menu(1) %>	  
  		<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
		
		<% if Menu(2) %>
			<ul id="Menu2">
				<% control Menu(2) %>			
					<li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle.XML</a></li>
				<% end_control %>
			</ul>
		<% end_if %> 
				
   	<% end_control %>
		

</ul>

Avatar
borriej

Community Member, 267 Posts

6 May 2010 at 9:08pm

Ok solved it with a bit of puzzling and the help of Sidebar.ss, but why does it need to be like this:

<ul>
 	<% control Menu(1) %>	  
  		<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
		
		<% if LinkOrSection = section %>
			<% control Children %>
				<ul id="Menu2">
						<li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle.XML</a></li>
				</ul>
			<% end_control %>
		<% end_if %>
		
   	<% end_control %>


</ul>