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

making a nested menu..


Go to End


5 Posts   5483 Views

Avatar
DHN

Community Member, 23 Posts

27 March 2008 at 9:31am

Edited: 29/03/2008 3:44am

i'm building a site, and everything is working fine, just have this one little thing that bothers me...

I wan't to have a nested menu, but i can't get it to work the way i want it... currently it's allmost working... using this code:

<% control Menu(2) %>
    <li><a href="$Link" title="Go to the &quot;{$Title}&quot; page" class="selected">$MenuTitle</a></li>
  <% control Children %><ul>
  <li><a href="$Link" title="Go to the &quot;{$Title}&quot; page" class="selected">$MenuTitle</a></li></ul>
<% end_control %><% end_control %>

but this makes the children of menu 2 show up always... i wan't it to show the children only of the current page, is there a way of doing this.

the menu can be seen here : http://www.djd.dk

Avatar
DHN

Community Member, 23 Posts

29 March 2008 at 3:46am

anyone please... put a link to the site in my other post if you want to have a look at the menu.

Avatar
(deleted)

Community Member, 473 Posts

29 March 2008 at 8:13am

Edited: 29/03/2008 8:42am

<% control Menu(2) %>

<li><a href="$Link" title="Go to the &quot;{$Title}&quot; page" class="selected">$MenuTitle</a></li>
<% if isSection %>
<% control Children %><ul>

<li><a href="$Link" title="Go to the &quot;{$Title}&quot; page" class="selected">$MenuTitle</a></li></ul>

<% end_control %>
<% end_if %>
<% end_control %>

Avatar
Willr

Forum Moderator, 5523 Posts

29 March 2008 at 9:55pm

isSection? Not sure that works. I know we have a inSection(). You can also check out how the default theme does it - I think it uses if LinkOrSection = section

Check out our docs for more info on these - http://doc.silverstripe.com/doku.php?id=built-in-page-controls

Avatar
(deleted)

Community Member, 473 Posts

30 March 2008 at 8:21am

LinkOrSection() uses isSection() (:

isSection() returns a bool, so no need for an extra check.