Jump to:

3445 Posts in 1031 Topics by 872 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: 1314 Views
  • Juanitou
    Avatar
    Community Member
    323 Posts

    sort() method in templates Link to this post

    Hi!

    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();
       $themes->sort('ID');
       return $themes;
    }

    ---

    <% control sortedThemes %>

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

    Thanks in advance,
    Juan

    1314 Views
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.