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

Multi-level Menu Help


Go to End


11 Posts   7736 Views

Avatar
peacho

Community Member, 5 Posts

21 July 2008 at 4:06pm

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. :)

Avatar
S0crates9

27 Posts

19 October 2008 at 10:36am

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!

Avatar
Willr

Forum Moderator, 5523 Posts

19 October 2008 at 3:44pm

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

Go to Top