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 /

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

Using Customized Children Loop within Children Loop


Go to End
Reply


3 Posts   1799 Views

Avatar
phawley

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

    $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

Forum Moderator, 5521 Posts

2 September 2011 at 8:08pm

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

Avatar
phawley

Community Member, 21 Posts

3 September 2011 at 1:43am

Perfect Will...thanks!