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

<if children> Menu(1) must look different


Go to End


3 Posts   3501 Views

Avatar
wonnepfropfen

Community Member, 18 Posts

2 June 2012 at 4:24am

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

Avatar
Willr

Forum Moderator, 5523 Posts

2 June 2012 at 12:20pm

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.

Avatar
wonnepfropfen

Community Member, 18 Posts

3 June 2012 at 1:12am

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.