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.

Template Questions /

Issue with menu levels


Reply


3 Posts   2031 Views

Avatar
fishe

Community Member, 42 Posts

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

Avatar
Willr

Forum Moderator, 5513 Posts

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

Avatar
fishe

Community Member, 42 Posts

14 July 2009 at 3:28pm

Thanks for the help will! :)