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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Sorting items / data


Go to End


2 Posts   1609 Views

Avatar
mexik

Community Member, 16 Posts

12 July 2011 at 10:29pm

Hi,

I have created special page like catalog with items in it but it'd like to sort them by date (newest on the top).
In my site tree it looks like that:

Catalog holder page |
- item page / date 1996
- item page / date 2001
- item page / date 2010

And i'd like to display those in a list sorted by date (newest on the top).
Help please ...

Avatar
swaiba

Forum Moderator, 1899 Posts

13 July 2011 at 12:07am

Edited: 13/07/2011 12:07am

I have no idea how to do this within the sitetree automatically (I know that you are able to manually re-order the pages).
But if it is within a DataObject::get then you can specific the sort order.

Possibly adding this to your page object would work - but as I said within the sitetree I don't know..

$default_sort = 'Created DESC';  //order by created date - I assume this is what you mean by "Date"