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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Using Customized Children Loop within Children Loop

Go to End

3 Posts   2513 Views


Community Member, 21 Posts

2 September 2011 at 3:30pm

Edited: 02/09/2011 3:31pm

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


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


Forum Moderator, 5523 Posts

2 September 2011 at 8:08pm

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


Community Member, 21 Posts

3 September 2011 at 1:43am

Perfect Will...thanks!