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

Using Customized Children Loop within Children Loop


Reply

3 Posts   1204 Views

Avatar
phawley

2 September 2011 at 3:30pm (Last edited: 2 September 2011 3:31pm), Community Member, 21 Posts

I'm trying to sort a list of Appearances within each month, and I have the customized Children control loop working for this in the month template, but in the Year template, first the Children control loop is called and then the customized Children control loop is called, and it returns nothing. The template currently works using standard Children control loops, though:

in Page.php:

public function SortedAppearances(){
// $children will be a DataObjectSet
$children = $this->Children();

if( !$children )
return null; // no children, nothing to work with

$children->sort('AppearanceDate');

// return sorted set
return $children;
}

in template:

<% control Children %>
...
<% if SortedAppearances %>
<% control SortedAppearances %>
...
<% end_control %>
<% end_if %>
...
<% end_control %>

Thanks in advance for any help.
Patrick

Avatar
Willr

2 September 2011 at 8:08pm Forum Moderator, 5511 Posts

SortedAppearances() needs to be in your Page model, not the controller.

Avatar
phawley

3 September 2011 at 1:43am Community Member, 21 Posts

Perfect Will...thanks!