Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » nested menus

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: 3913 Views
  • tito0224
    Avatar
    Community Member
    8 Posts

    nested menus Link to this post

    Is this type of menu nesting possible?

    <div id="menu_vert">
       <ul>
          <% control Menu(2) %>
           <li class="$LinkingMode"> <a href="$Link" alt="$Title"><dfn> </dfn>$MenuTitle</a>
                <% if Menu(3) %>
                   <ul>            
           <% control Menu(3) %>
                      <li><a href="$Link" alt="$Title"><dfn> </dfn>$MenuTitle</a></li>
                    <% end_control %>
                   <ul/>
                <% end_if %>
           </li>         
    <% end_control %>
       </ul>
    </div>

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: nested menus Link to this post

    That should work Or you could try controlling the children of the menu 2 if this method does not work.

  • pouderStream
    Avatar
    Community Member
    33 Posts

    Re: nested menus Link to this post

    Doesn't work becouse Menu() is top level
    I tried that when I was making my multilevel menu.I sadly don't have access to that code anymore, but I'll remake it tomorow. It's not hard ;) u should use <% control Children %>...

  • tito0224
    Avatar
    Community Member
    8 Posts

    Re: nested menus Link to this post

    would I just replace <% control Menu(3) %> with <% control Children %> because this does not seem to work

    thanks!

  • tito0224
    Avatar
    Community Member
    8 Posts

    Re: nested menus Link to this post

    thanks for the help! got it working

  • Kim
    Avatar
    Community Member
    5 Posts

    Re: nested menus Link to this post

    Can you post your solution? I am trying to get the same thing working.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: nested menus Link to this post

    This is what I usually do when making nested menu's:

    <ul id="Menu1">
    <% control Menu(1) %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>>
    <a href="$Link" title="View page $MenuTitle">$MenuTitle</a>
    <% if Children %>
    <ul class="Menu2">
    <% control Children %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>>
    <a href="$Link" title="View page $MenuTitle">$MenuTitle</a>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>

    Something like this should get you 2 levels, just keep nesting <% control Children %> if you want 3 levels deep, or more.

    Also, if you only want to show the children currently in the section you're in, just nest <% if LinkOrSection = section %> after <% if Children %>.

  • sonicparke
    Avatar
    74 Posts

    Re: nested menus Link to this post

    This doesn't seem to be working for me. Is this the code I would put in my navigation include because that's where I put it. Since it's in there I'm assuming that in Page.ss I only need <% include Navigation %>. But I'm not getting my neted menu. Just Menu(1).

    3913 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.