Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » navigation query

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

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

Page: 1
Go to End
Author Topic: 2180 Views
  • Stevie G
    Avatar
    Community Member
    4 Posts

    navigation query Link to this post

    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

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: navigation query Link to this post

    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.

  • Stevie G
    Avatar
    Community Member
    4 Posts

    Re: navigation query Link to this post

    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.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: navigation query Link to this post

    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?

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: navigation query Link to this post

    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 %>

  • Stevie G
    Avatar
    Community Member
    4 Posts

    Re: navigation query Link to this post

    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.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: navigation query Link to this post

    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.

  • motoservo
    Avatar
    Community Member
    24 Posts

    Re: navigation query Link to this post

    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

    2180 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.