Jump to:

3392 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » <if children> Menu(1) must look different

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

Page: 1
Go to End
Author Topic: 923 Views
  • wonnepfropfen
    Avatar
    Community Member
    18 Posts

    <if children> Menu(1) must look different Link to this post

    Hi there

    I'm struggeling with the following problem.

    Everytime Menu(1) has got children, Menu(1) has to to look different than the other main menu links.

    For now my structure looks something like this:

    <ul id="Navigation">
    <% control Menu(1) %>
       <li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a>
          <% if LinkOrSection = section %>
             <% if Children %>
                <ul id="Sub-Menu">
                <% control Children %>
                <li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a>
                <% if LinkOrSection = section %>
                   <% if Children %>
                         <ul id="Subsub-Menu">
                         <% control Children %>
                         <li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"<% end_if %>>$MenuTitle</a></li>
                         <% end_control %>
                         </ul>
                   <% end_if %>
                <% end_if %>
                </li>
                <% end_control %>
                </ul>
             <% end_if %>
          <% end_if %>
       </li>
    <% end_control %>
    </ul>

    Would anyone know how to do it? I hope you understand what I mean. It's hard to explain.

    Thanks

    Jessi

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: <if children> Menu(1) must look different Link to this post

    I'm not sure I follow by has to 'look' different. You can use something like <% if Children %>class="has-children"<% end_if %> to add a class to something if it has children. Read up on the template controls documentation page for all the template controls you can use.

  • wonnepfropfen
    Avatar
    Community Member
    18 Posts

    Re: <if children> Menu(1) must look different Link to this post

    I'm still struggling with this problem. I have tried lot's of stuff, but sometimes the menu disappears and then it appears twice etc. I've also read controls documentation, but still no clue.

    Could you please have a look at the attached pic and tell me if this is possible to do. Maybe I can stop trying.

    923 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.