3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 622 Views |
-
SS 3.0.3 - Loop children not limited to children of current page - SOVLED

22 December 2012 at 4:20am
I'm testing out SilverStripe 3.0.3, and I find the side behaving strange. I see that the code has changed in the simple template from using <% loop menu(2) %> to using <% loop $Children %>
Anyway, the result is that I get all children of every page showing up on everypage with children. Is there any bugs in the built in template controls? I mean loop children should normally only loop through the children of the specific page?
This is the new SidebarMenu simple template code:
<%--Include SidebarMenu recursively --%>
<% if $Children %>
<% loop $Children %>
<li class="$LinkingMode">
<a href="$Link" class="$LinkingMode" title="Go to the $Title.XML page">
<span class="arrow">→</span>
<span class="text">$MenuTitle.XML</span>
</a><% if $Children %>
<ul>
<% include SidebarMenu %>
</ul>
<% end_if %></li>
<% end_loop %>
<% end_if %> -
Re: SS 3.0.3 - Loop children not limited to children of current page - SOVLED

22 December 2012 at 12:58pm Last edited: 22 December 2012 12:59pm
I found that in the SideBar.ss include it is defined a loop through $Menu(1) for the SidebarMenu.ss include. Like this:
<aside>
<% if $Menu(2) %>
<nav class="secondary">
<h3>
<% loop $Level(1) %>
$Title
<% end_loop %>
</h3>
<ul>
<% loop $Menu(1) %>
<% include SidebarMenu %>
<% end_loop %>
</ul>
</nav>
<% end_if %>
</aside>That is why the sidebar menu shows the children of all of the first level pages instead of showing only the children of the current page as we are used to in SilverStripe. I don't know if this are some kind of a new idea or just a mistake, but to get it work as I intended I just deleted the loop around the <% include SidebarMenu %>. Just like this:
<aside>
<% if $Menu(2) %>
<nav class="secondary">
<h3>
<% loop $Level(1) %>
$Title
<% end_loop %>
</h3>
<ul>
<% include SidebarMenu %>
</ul>
</nav>
<% end_if %>
</aside>Hope this could be to any help for other confused SilverStripers.
Merry Christmas to all of you!
-
Re: SS 3.0.3 - Loop children not limited to children of current page - SOVLED

17 January 2013 at 6:17am
Thank you for this!
d -
Re: SS 3.0.3 - Loop children not limited to children of current page - SOVLED

17 January 2013 at 6:57pm
Just to clarify: this thread is referring to the Simple theme that is included in SS 3.
The code that Thomashv provided is close but not quite there. It won't provide menus when you are in the child pages. The following code for SideBar.ss has been posted in github and should be in the next version. Meanwhile, here it is for anyone who has found this thread<aside>
<% if $Menu(2) %>
<nav class="secondary">
<% with $Level(1) %>
<h3>
$Title
</h3>
<ul>
<% include SidebarMenu %>
</ul>
<% end_with %>
</nav>
<% end_if %></aside>
-
Re: SS 3.0.3 - Loop children not limited to children of current page - SOVLED

16 May 2013 at 7:43am
And then a half year almost was gone... But thank you very much for the clearification.
| 622 Views | ||
|
Page:
1
|
Go to Top |



