Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Question about "Childen" in sample BlackCandy SideBar.ss template

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

Page: 1
Go to End
Author Topic: 339 Views
  • xm
    Avatar
    Community Member
    3 Posts

    Question about "Childen" in sample BlackCandy SideBar.ss template Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Question about "Childen" in sample BlackCandy SideBar.ss template Link to this post

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

  • xm
    Avatar
    Community Member
    3 Posts

    Re: Question about "Childen" in sample BlackCandy SideBar.ss template Link to this post

    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.

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