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

Question about "Childen" in sample BlackCandy SideBar.ss template


Go to End


3 Posts   1188 Views

Avatar
xm

Community Member, 3 Posts

23 November 2012 at 4:05pm

Hi

In the BlackCandy theme folder there's an SS called SideBar.ss and the logic in here is killing me. Here it is...
<ul id="Menu2">
<% control Menu(2) %>
<% if Children %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle.XML</em></span></a>
<% else %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle.XML</em></span></a>
<% end_if %>

<% if LinkOrSection = section %>
<% if Children %>
<ul class="sub">
<li>
<ul class="roundWhite">
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levelb"><span><em>$MenuTitle.XML</em></span></a></li>
<% end_control %>
</ul>
</li>
</ul>
<% end_if %>
<% end_if %>
</li>
<% end_control %>
</ul>
-----------------------
Why is it when there is children it stops there? Why wont it dig deep to flesh it out and when it has no children (the else) it looks for other menu items within?

Thanks for your help

Avatar
Willr

Forum Moderator, 5523 Posts

2 December 2012 at 5:48pm

Not sure I follow the question, the <% else %> statement is unrelated to the following <% if Children %> (notice the <% end_if %> in between). The top <% if Children %> is used it appears to just add another class.

<% if Children %> will execute if the page currently in scope has children pages (if your pages are 'hidden' in the sitetree they will not be included).

Avatar
xm

Community Member, 3 Posts

4 December 2012 at 3:01pm

Hi

Thanks for your reply.

I'm sorry for coming across as incoherent. There is nothing wrong with the code, of course, but the book I am reading uses this as an example and has misleading whitespacing -- making the if statements out of place.

Thanks again,
xm.