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.
Like the title say I've got a many_many relation and when I show the objects in the front end they need to be sorted by product ID numbers that the client sets. But when I use <% control Products %> they are called up in the order they were created.
Is there away of achieving this that I haven't found or will I have to create a custom method that calls Dataobject::get().
You can do this:
<% if Products %>
<% control Products %>
<% end_control %>
<% end_if %>
But due to an annoying limitation of SSViewer, you can't set the order (it is ascending by default). For anything more complicated you'll need your own method.
Thank you, that should do just what I need.
Is there an entry in the documentation that covers this or other built in functions that can be applied in the template?
Thanks dalesaurus, that is a good reference but there's nothing there about a sort() method. Just a reference to the Sort field in the Sitetree table of the database.
I've been experimenting and found that the method is coming from the DataObjectSet class which should help answer most of the questions I have. I expect that I'll be back if it doesn't.
Anyone know what other core classes I can expect to show up in the templates? I'm assuming their methods would be available in the same way.