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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Make children collapse


Go to End


2 Posts   1252 Views

Avatar
R6T9

Community Member, 1 Post

5 May 2012 at 12:52am

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

Community Member, 135 Posts

7 May 2012 at 6:30pm

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