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.

Archive /

Our old forums are still available as a read-only archive.

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

nested menus


Go to End


8 Posts   4590 Views

Avatar
tito0224

Community Member, 8 Posts

16 April 2007 at 9:48am

Is this type of menu nesting possible?

<div id="menu_vert">
<ul>
<% control Menu(2) %>
<li class="$LinkingMode"> <a href="$Link" alt="$Title"><dfn> </dfn>$MenuTitle</a>
<% if Menu(3) %>
<ul>
<% control Menu(3) %>
<li><a href="$Link" alt="$Title"><dfn> </dfn>$MenuTitle</a></li>
<% end_control %>
<ul/>
<% end_if %>
</li>
<% end_control %>
</ul>
</div>

Avatar
Willr

Forum Moderator, 5523 Posts

16 April 2007 at 9:58am

That should work :D Or you could try controlling the children of the menu 2 if this method does not work.

Avatar
pouderStream

Community Member, 33 Posts

16 April 2007 at 10:47am

Edited: 16/04/2007 12:38pm

Doesn't work becouse Menu() is top level :)
I tried that when I was making my multilevel menu.I sadly don't have access to that code anymore, but I'll remake it tomorow. It's not hard ;) u should use <% control Children %>...

Avatar
tito0224

Community Member, 8 Posts

16 April 2007 at 11:25am

would I just replace <% control Menu(3) %> with <% control Children %> because this does not seem to work

thanks!

Avatar
tito0224

Community Member, 8 Posts

16 April 2007 at 1:29pm

thanks for the help! got it working

Avatar
Kim

Community Member, 5 Posts

21 April 2007 at 4:58pm

Can you post your solution? I am trying to get the same thing working.

Avatar
Sean

Forum Moderator, 922 Posts

22 April 2007 at 2:01pm

Edited: 22/04/2007 7:53pm

This is what I usually do when making nested menu's:

<ul id="Menu1">
<% control Menu(1) %>
<li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>>
<a href="$Link" title="View page $MenuTitle">$MenuTitle</a>
<% if Children %>
<ul class="Menu2">
<% control Children %>
<li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>>
<a href="$Link" title="View page $MenuTitle">$MenuTitle</a>
</li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>

Something like this should get you 2 levels, just keep nesting <% control Children %> if you want 3 levels deep, or more. :-)

Also, if you only want to show the children currently in the section you're in, just nest <% if LinkOrSection = section %> after <% if Children %>.

Avatar
sonicparke

74 Posts

8 November 2007 at 7:01am

This doesn't seem to be working for me. Is this the code I would put in my navigation include because that's where I put it. Since it's in there I'm assuming that in Page.ss I only need <% include Navigation %>. But I'm not getting my neted menu. Just Menu(1).