Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » Make children collapse

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

Page: 1
Go to End
Author Topic: 470 Views
  • R6T9
    Avatar
    Community Member
    1 Post

    Make children collapse Link to this post

    Hi! I am all new to SilverStripe. I am learning SilverStripe because I really like the CMS. I am starting my own company and I want my site to be SS based. I really can use your help. If if have something like this:

    <% control Menu(1) %>
    // ul - li etc //
    <% control Children %>
    // ul - li etc //
    <% end_control %>
    <% end_control %>

    The children just won't disappear. They are visible no matter what parent item is active. Now I can use jQuery or some PHP to make them successfully disappear, but I rather have SilverStripe to do so. I don't actually need this for my own site, but I just want to learn SS the best way possible, so that my own site will be as clean and fast as possible. Thank you so much!

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: Make children collapse Link to this post

    What you want is to check if the current page is the page or a descendant of the menu item using LinkOrSection:

    <% control Menu(1) %>
       // ul - li etc //
       <% if LinkOrSection = section %>
       <% control Children %>
       // ul - li etc //
       <% end_control %>
       <% end_if %>
    <% end_control %>

    http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#and-lt-if-linkorsection-section-and-gt

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