Jump to:

1016 Posts in 567 Topics by 309 members

Forum Module

SilverStripe Forums » Forum Module » Order of items different on admin and published site.

Discuss the Forum Module.

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

Page: 1
Go to End
Author Topic: 1258 Views
  • lakum4SS
    Avatar
    Community Member
    2 Posts

    Order of items different on admin and published site. Link to this post

    The problem I am facing is that the items I have added in admin are published in different order on site. i.e I want to say is like this...
    In admin
    - News
    -- Article1
    -- Article2
    -- Article3

    and they are published in this order.
    - News
    -- Article3
    -- Article1
    -- Article2

    Help me to solve this problem. I want the order of items same in both admin and published site.

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Order of items different on admin and published site. Link to this post

    You need to write a function to do the sorting...

    this is taken from Tutorial 2

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    $records = DataObject::get($obj, $filter, $sort, $join, $limit);

    The "Date DESC" is the part doing the sorting, if left blank, it's using your SiteTree order. ASC order is the default, so "Date ASC" and "Date" are the same. You can sort by "Created DESC" or "LastEdited" or fields in your static $db = array(), etc.

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