Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » sort() method in templates

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

Page: 1
Go to End
Author Topic: 1305 Views
  • Juanitou
    Community Member
    323 Posts

    sort() method in templates Link to this post


    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,

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.