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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

Sort Article List Chronologically

Go to End

2 Posts   1353 Views


Community Member, 63 Posts

3 December 2010 at 9:33pm

Is there any way to have an article list (ie; on an ArticleHolder page) displayed so it's sorted in chronological order with most recent articles displayed at the top?
...other than manually sorting the pages by dragging and dropping them up the list in the CMS


Forum Moderator, 1899 Posts

5 December 2010 at 3:04am

Assuming you are talking about...

something like this in your controller...

function ArticlesOrderedByCreated() {
  return  DataObject::get("ArticleHolder","","Created ASC");

then this in your controller...

<% if ArticlesOrderedByCreated %>
 <% control ArticlesOrderedByCreated %>
 	$Date <br />
 	$Author <br />
 	$Content <br /> 
 <% end_control %>
<% end_if %>

every dataobject (including pages or anything you create) has a "Created" and "LastEditted" value set automatically when you create it and when you edit it.