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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Pages order in menu/cms


Go to End


12 Posts   7599 Views

Avatar
Tonyair

Community Member, 81 Posts

25 June 2010 at 3:23am

Try it =)
class ArticleHolder_Controller extends Page_Controller {

/**
* Get the latest 2 news articles, allowing us to get more
*
* @return DataObjectSet|false The DataObjectSet of the news articles you're looking at or boolean false if there aren't any news articles
**/
function NewsArticles() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$doSet = DataObject::get(
$callerClass = "ArticlePage",
$filter = "`ParentID` = '".$this->ID."'",
$sort = "Date DESC",
$join = "",
$limit = "{$SQL_start},10"
);
return $doSet ? $doSet : false;
}

}

Avatar
Terry Apodaca

Community Member, 112 Posts

23 February 2011 at 8:49am

I've tried several of these, and a few of my own. I have to say that they are all very inconsistent. VERY inconsistent....so I just tell the client that the menu will show up in the same order it does in the tree of the CMS. If they want it changed, they can click the Drag and Drop Reordering to place them in the order they want. so my sort is empty:

static $default_sort = '';

Avatar
johnp

Community Member, 8 Posts

25 September 2012 at 11:00pm

Did any body find an answer to this? been rattling my brain with this problem!
If so could you please post

Avatar
Fountain

Community Member, 1 Post

30 April 2013 at 3:50am

This thread put me on the right track (I'm using SS 3). Open your site's _config.php file and add the following line:

SiteTree::$default_sort = 'Title';

Replace Title with whatever column you want to sort the tree on.

Go to Top