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

navigation query


Go to End


8 Posts   3086 Views

Avatar
Stevie G

Community Member, 4 Posts

29 August 2008 at 10:52pm

Hi folks,
Well - my first SilverStripe post.

I have a query regarding dynamic navigation. Obviously each menu item is added as a page is published.

On the site I'm planning, I have a horizontal nav menu and vertical. How do I dictate which page appears on which menu?

Thanks,
S

Avatar
Liam

Community Member, 470 Posts

30 August 2008 at 2:08am

Is this something like the horizontal nav is for the main, top level links, and the vert nav is for the sub pages?

If so, check out the blackcandy theme that comes included. It is setup like this already. Dig through the templates to see how its down.

Or you mean you have 2 navs for different pages and they never show up at the same time? You'd have to setup different page types for each by extending the Page class and associate the template with just the code. Or run a bunch of <% if inSection(page) %> checks in your template to see which page you're on and display the correct nav.

Avatar
Stevie G

Community Member, 4 Posts

30 August 2008 at 2:20am

Not quite.

This probably better explains the idea of what I want to achieve:

http://www.yaml.de/fileadmin/examples/07_navigation/menu_vertical_listnav.html

The horizontal menu is level 1 and then there are items on the vertical menu that are also level 1.

Avatar
Liam

Community Member, 470 Posts

30 August 2008 at 4:06am

That is pretty much like the menu in blackcandy except the vert shows level ones as well. That could easily be changed by editing the menu code and which levels are displayed. If you look at SideBar.ss you'll see the code is to just display Menu(2), so what you'd want to do is include Menu(1) wrapped around it following the same concept as the nested ones. <% if Children %> etc.

Maybe I'm still missing something. Are the level 1s in the horizontal the same as the level 1s in the vertical or are you trying to leave some out?

Avatar
grilldan

Community Member, 135 Posts

30 August 2008 at 5:07am

Edited: 30/08/2008 5:08am

This might help you.
(from coffeeNcream theme)

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

Avatar
Stevie G

Community Member, 4 Posts

30 August 2008 at 6:22am

I want to define what level 1's (and how many) to show in the horizontal and the rest in the vertical.

In the Coffee theme the vertical menu just repeats the horizontal.

Avatar
Liam

Community Member, 470 Posts

1 September 2008 at 11:57am

There isn't really a great way to do that. An option might be to uncheck the 'show in menu' option in the behavior tab, then in your template use <% control AllChildren %> to show them all in the nav you want all of them.

Avatar
motoservo

Community Member, 27 Posts

14 November 2008 at 8:32am

You can create a menu that is separate from, and independent of, the main menu. I use this technique to create a secondary menu that I use for a footer:

http://doc.silverstripe.com/doku.php?id=recipes:page_selection_for_special_menu