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

Make children collapse


Reply

2 Posts   495 Views

Avatar
R6T9

5 May 2012 at 12:52am Community Member, 1 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!

Avatar
3dgoo

7 May 2012 at 6:30pm Community Member, 133 Posts

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