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.

Template Questions

Splitting ChildrenOf


Reply

3 Posts   631 Views

Avatar
Nev

29 January 2011 at 12:47am Community Member, 5 Posts

Hi Everyone,

Have a quick question I am looking to split the nodes of the ChildrenOf results. For example

<div class="inner-box">
<ul class="bor-none">
<% control ChildrenOf(about-us) DISPLAY FIRST 4 %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>
<ul>
<% control ChildrenOf(about-us) DISPLAY SECOND 4 %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
<ul>
<% control ChildrenOf(about-us) DISPLAY THIRD 4 %>
<li><a href="$Link">$MenuTitle</a></li>
<% end
<span class="clear"></span> </div>
</div>

Any help would be greatly appreciated !

Thanks

Avatar
swaiba

29 January 2011 at 12:52am (Last edited: 29 January 2011 12:54am), Forum Moderator, 1796 Posts

in your Page_controller do something like...

public function LimitedChildrenOf($parentRef,$iLimit) {
   $dos = $this->ChildrenOf($parentRef);
   return $dos->getRange(0,$iLimit);
}

(note untested)

Avatar
Nev

30 January 2011 at 3:04am Community Member, 5 Posts

Thanks swaiba, used the following in the controller:

public function LimitedChildrenOf($parentRef, $offset, $length) {
$dos = $this->ChildrenOf($parentRef);
return $dos->getRange($offset, $length);
}

and in the template:

<% control LimitedChildrenOf(directory/mypage/, 0, 4 %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>

<% control LimitedChildrenOf(directory/mypage/, 3, 4 %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>

etc

Simples !