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.

Data Model Questions /

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

Sort ComplexTableField in the CMS


Go to End


2 Posts   2785 Views

Avatar
MarioSommereder

Community Member, 107 Posts

22 June 2009 at 2:41am

Edited: 22/06/2009 9:35am

Hi,

I've got a simple news section made with DataObjects. Everything works fine, I just want to sort the entries by date.

$newsTable = new ComplexTableField(
	$this,
	'NewsArticles',
	'NewsArticle',
	array(
		'ArticleDate' => 'Article Date',
		'ArticleTitle' => 'Article Title'
	),
	null
);

Can anyone give me a hint? Thanks!

Avatar
MarioSommereder

Community Member, 107 Posts

22 June 2009 at 9:34am

Edited: 22/06/2009 9:34am

Ahhh, that's how it works:

$newsTable = new ComplexTableField(
	$this,
	'NewsArticles',
	'NewsArticle',
	array(
		'ArticleDate' => 'Article Date',
		'ArticleTitle' => 'Article Title'
	),
	null,
	null,
	'ArticleDate DESC'
);