Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » [SOLVED] Inverted sorting of children

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

Page: 1
Go to End
Author Topic: 1344 Views
  • stevenlangbroek
    Avatar
    Community Member
    3 Posts

    [SOLVED] Inverted sorting of children Link to this post

    I've built a basic site, and have extended it somewhat. I now have the ArticleHolder and ArticlePage-children. However, I want to sort them in inverted order (in relation to the sitetree). So uhmm... do i place a statement in the control children, in the ArticleHolder or ArticlePage? I don't get it... (yes it's a noob question, I know... I'm learning)

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: [SOLVED] Inverted sorting of children Link to this post

    You will need to add a custom function to your ArticleHolder which calls sort() on the children.

    function OrderedChildren() {
    $oc = $this->Children();
    $oc->sort('Sort DESC');
    return $oc;
    }

    Then instead of using <% control Children %> you can use <% control OrderedChildren %>

  • stevenlangbroek
    Avatar
    Community Member
    3 Posts

    Re: [SOLVED] Inverted sorting of children Link to this post

    Wow... it's that easy huh? Thanks for being so helpful, I'm on plenty of forums and questions with such obvious answers usually get flamed to bits, so props where props are due!

    1344 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.