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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Vertical Menu problem - want level 1 and level 2 to be visible


Reply

2 Posts   1083 Views

Avatar
borriej

6 May 2010 at 8:49pm (Last edited: 6 May 2010 9:00pm), Community Member, 267 Posts

Hello

I have a vertical menu with the level 1 pages displayed.
When you click on a page that has children it should display them.
See example.

[URL=http://img202.imageshack.us/i/verticalmenu.jpg/][/URL]

So i thought this code should do the trick, but it doesn't do anything. I'm only seeing level 1.

In page.php I have enabled children.

static $allowed_children = array('Page');

<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 class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle.XML</a></li>
            <% end_control %>
         </ul>
      <% end_if %>
            
   <% end_control %>
      

</ul>

Avatar
borriej

6 May 2010 at 9:08pm Community Member, 267 Posts

Ok solved it with a bit of puzzling and the help of Sidebar.ss, but why does it need to be like this:

<ul>
   <% control Menu(1) %>   
      <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
      
      <% if LinkOrSection = section %>
         <% control Children %>
            <ul id="Menu2">
                  <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle.XML</a></li>
            </ul>
         <% end_control %>
      <% end_if %>
      
   <% end_control %>

</ul>