2864 Posts in 732 Topics by 700 members
Template Questions
SilverStripe Forums » Template Questions » Issue with menu levels
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1460 Views |
-
Issue with menu levels

11 July 2009 at 12:05pm
Hey
I have the following code in a Includes/Navigation.ss file:
<ul>
<% control Menu(1) %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li><% if Menu(2) %>
<ul id="Menu2">
<% control Menu(2) %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li><% end_control %>
</ul>
<% end_if %><% end_control %>
</ul>And the Page.ss simply does a: <% include Navigation %>
My problem is that the list output from Navigation.ss is not including the second level (i.e. Menu(2) ). However, there is a menu(2) existing for one of the top level menu items, and this is correctly outputted on that item's page (e.g. when I click that page - as in Layout/Page.ss there is output code similar to above to show the Menu(2) items and breadcrumbs etc.)
So basically, it will find/output menu(2) only when the page that actually has a menu(2) component is "active" - and not just on the homepage for example.
What could be going wrong here?
Thanks
-
Re: Issue with menu levels

11 July 2009 at 3:45pm
Menu(2) returns the menu for the current page, not the page within the loop.
Instead of doing the <% control Menu(2) %> inside the <% control Menu(1) %> you need to do <% control Children %> instead. To make sure the 2nd level is only shown when you are on that parent page or a child page of that you can wrap the <% control Children %> in a <% if LinkOrSection = section %> which will return true if you are on that page or a child of that page
| 1460 Views | ||
|
Page:
1
|
Go to Top |


