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.

Template Questions /

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

[solved] sort all subpages by date(subpages seperated in 2 categories on one site)

Go to End

5 Posts   952 Views


Community Member, 72 Posts

26 August 2011 at 8:31am

if got this site construction

ReferencesPage.php -
ReferencePage.php - -

It looks like this and this

The References are seperated in New and Old ones. But not sorted by Date. Cause i don't know how :/

I want that all the New References are sorted by date. latest ones at first. and the same with the old refernces.

Can someone tell me how?

Thx Benni


Forum Moderator, 1203 Posts

26 August 2011 at 11:23pm

I'm not quite sure about this - links to a page that has <scr + ipt links and a somewhat erotic popup, but don't seem to make the question any clearer?

Still - since you're not a new member, maybe we should give you a change to explain?


Community Member, 72 Posts

27 August 2011 at 7:34am

Edited: 27/08/2011 7:37am

hmm perhaps it's a little bit clearer if you visit the site
E-Mail: silverstripe
Password: ss123

there you can see that the references are seperated into new and old. but they aren't sorted by date, they are shown in the order i created them. and i don't know how to sort the new ones and the old ones.

do you know now what i mean?



Forum Moderator, 1203 Posts

27 August 2011 at 9:29pm

Edited: 27/08/2011 9:30pm

OK, I get it :-)

I wasn't sure if they were your pages the links referred to, so especially with the popup and all, they did look somewhat spammish. You might want to remove these links from your earlier post...

As for your question: I would create a custom function getReferences() in your ReferencesPage_controller, that retreives the ReferencePages in the correct order. Then use <% control References %> instead of <% control Children %> in your template.

You can then sort them by Date descending. Something like (simplest version thinkable):

public function getReferences() {
	return DataObject::get('ReferencePage', "ParentID = '$this->ID'", 'Date DESC');


Community Member, 72 Posts

28 August 2011 at 7:49am

Thanks! :)

I tried this function before too. but i made one mistake, i put it after <% control children %>, damn! :D

now it works fine.