Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Multi-level Menu Help

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

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

Page: 1 2
Go to End
Author Topic: 5806 Views
  • peacho
    Avatar
    Community Member
    5 Posts

    Re: Multi-level Menu Help Link to this post

    Thanks a ton! I've refined it a little, and will probably continue to as I figure more things out with it, but that got it working about 98% as I wanted.

  • S0crates9
    Avatar
    27 Posts

    Re: Multi-level Menu Help Link to this post

    For some reason I just don't understand how these menu's derive. For example, I am using the Nature4web template to learn from and they have the following code:

    <h3>Navigate</h3>
    <ul id="Navigation">
    <% control Menu(1) %>
    <li>
    <a class="$LinkingMode" href="$Link" title="Go to the $Title.XML page">$MenuTitle<span></span></a>
    <% if Children %>
    <% if LinkingMode = section %>
    <ul id="Sub-Menu">
    <% control Children %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>">
    <% if LinkingMode = current %>
    <a class="items" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% else %>
    <a class="item" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>
    <% if LinkingMode = current %>
    <ul id="Sub-Menu">
    <% control Children %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>">
    <% if LinkingMode = current %>
    <a class="items" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% else %>
    <a class="item" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>

    <% end_if %>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>

    what I want to achieve is a third level menu which I would assume includes a block like:

    <% if Children %>
    <% control Children %>
    <a class="item" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% end_control %>
    <% end_if %>

    Does anyone know what I am doing wrong?

    The menu nav should appear as follows:

    Home
    Section
    Sub-Page

    but the sub-page never renders or when I've gotten it to partially work, it shows up at Section level instead of Sub-page level...

    thanks for anyone's help in advance!

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: Multi-level Menu Help Link to this post

    Its because you have that wrapped inside a <% if LinkingMode = current %> . this will only return true if you are on the section page. You need to change that to if LinkOrSection = section which will return true if you are on that page (eg the main section page) or a child of the section page

    5806 Views
Page: 1 2
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.