Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » How to display news sorted by date?

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

Page: 1
Go to End
Author Topic: 1923 Views
  • HarryKC
    Avatar
    Community Member
    8 Posts

    How to display news sorted by date? Link to this post

    I would like to display news sorted by date instead of the order they are in the CMS.

  • simon_w
    Avatar
    Forum Moderator
    473 Posts

    Re: How to display news sorted by date? Link to this post

    I'm assuming that you're using the News articles from the tutorial.

    One way of doing this is to add your own method to the ArticleHolder in ArticleHolder.php, something like

    function OrderedChildren() {
       return DataObject::get('ArticlePage', 'ParentID = ' . $this->ID, 'Date DESC');
    }

    Then, in your template, instead of using <% control Children %>, you'll use <% control OrderedChildren %>

  • HarryKC
    Avatar
    Community Member
    8 Posts

    Re: How to display news sorted by date? Link to this post

    Thanks! Yes this was from the tutorial.

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