Jump to:

23003 Posts in 11856 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Vertical Menu problem - want level 1 and level 2 to be visible

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

Page: 1
Go to End
Author Topic: 1022 Views
  • borriej
    Avatar
    Community Member
    267 Posts

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

    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.

    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>

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Vertical Menu problem - want level 1 and level 2 to be visible Link to this post

    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>

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