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   6074 Views

Avatar
peacho

Community Member, 5 Posts

28 June 2008 at 12:15pm

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

Forum Moderator, 5513 Posts

28 June 2008 at 7:24pm

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

Community Member, 5 Posts

29 June 2008 at 12:51pm

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

Forum Moderator, 5513 Posts

29 June 2008 at 1:04pm

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

Avatar
peacho

Community Member, 5 Posts

30 June 2008 at 4:37am

Edited: 30/06/2008 4:37am

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

Forum Moderator, 5513 Posts

30 June 2008 at 9:12am

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

Community Member, 5 Posts

21 July 2008 at 11:18am

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

Forum Moderator, 5513 Posts

21 July 2008 at 11:57am

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