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:

Template Questions /

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

sort() method in templates

Go to End



Community Member, 323 Posts

29 September 2009 at 7:06am

Edited: 29/09/2009 7:08am


Some pages of a site have related ThemePages (many_many as Themes => ThemePage). I can show them easily with:

<% control Themes %>

Only, they are not sorted as I would like to. I’m certainly doing something stupid, since using:

<% control Themes.sort(ID) %>

…renders nothing, but this works:

function sortedThemes() {
	$themes = $this->Themes();
	return $themes;


<% control sortedThemes %>

Well, I know I can use $default_sort = '`SiteTree`.ID', but I’m curious… :)

Thanks in advance,