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.

Archive

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

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

Multi-level Menu Help


Go to End
Reply

11 Posts   5913 Views

Avatar
peacho

28 June 2008 at 12:15pm Community Member, 5 Posts

Hi. I'm having an issue making a multi-level menu. I have this setup in my admin-view-tree.

However, I can only get two levels to show up on the actual page's sidebar. I attempted to do some code hacking on the .ss page, but couldn't quite get it. Could someone give me some guidance?

Avatar
Willr

28 June 2008 at 7:24pm Forum Moderator, 5511 Posts

Are you using the blackcandy theme? I think it should support at least 4 levels - first level in the tabs, then 3 levels on that sidebar... So try have a look at that Sidebar.ss file

So you would have this sort of structure for 3 levels in the same nav

<% control Menu(1) %>
// outputs top level - Product Support
<% control Children %>
// outputs BCC Support, BCC worksheet etc
<% control Children %>
// Outputs 3rd level - Codename Topaz..
<% end_control %>
<% end_control %>
<% end_control %>

Avatar
peacho

29 June 2008 at 12:51pm Community Member, 5 Posts

I am using the "Pluralism" theme. So a setup like the one you posted should work? And if so, is there some specific order (inside/outside/etc.) I need to put the <ul> and </ul> tags in to create a indented list?

Avatar
Willr

29 June 2008 at 1:04pm Forum Moderator, 5511 Posts

if you want to indent the list then you should nestle the ul so like http://pastie.org/224229

Avatar
peacho

30 June 2008 at 4:37am (Last edited: 30 June 2008 4:37am), Community Member, 5 Posts

I applied the code in the pastie and it did make a change, however now instead of dynamically showing the levels, it always shows every page on the site, and there are no indentations:

[URL=http://img370.imageshack.us/my.php?image=alllinkssl7.png][/URL]

I'm sorry that I have to ask for all the help, but this is really my first time actually using SilverStripe for a project.

Avatar
Willr

30 June 2008 at 9:12am Forum Moderator, 5511 Posts

You have to use CSS to control the indentations. HTML alone doesnt work. Try something like below. Im assuming the sidebar has a id of #Sidebar

#Sidebar ul ul {
margin-left: 10px;
}

Avatar
peacho

21 July 2008 at 11:18am Community Member, 5 Posts

This is kind of a large bump, so apologies for that. I've fixed a few bugs, but am stuck with one. Instead of only showing the children of the current page/section, it shows every page and every subpage within it.

[URL=http://img144.imageshack.us/my.php?image=alllinks2hg1.png][/URL]

This is my current Sidebar.ss file:

<ul>
<% control Menu(1) %>
<li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a>
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a>
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>

Avatar
Willr

21 July 2008 at 11:57am Forum Moderator, 5511 Posts

if you only want to show the children on the selected page then you have to nestle the 2nd and 3rd control Children in a command to detect if they are in the Current Section by using LinkOrSection = section which will return true if you are on that page or a child of that page (eg in the same section of the tree

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

Go to Top