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.

Forum Module /

Discuss the Forum Module.

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

Order of items different on admin and published site.


Reply


2 Posts   1379 Views

Avatar
lakum4SS

Community Member, 2 Posts

3 October 2009 at 8:30pm

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.

Avatar
socks

Community Member, 190 Posts

12 October 2009 at 8:31pm

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.