22848 Posts in 9653 Topics by 2803 members
|Go to End|
16 October 2009 at 12:14am Last edited: 16 October 2009 12:15am
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().
16 October 2009 at 1:20pm
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.
16 October 2009 at 3:17pm
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?
16 October 2009 at 3:49pm
17 October 2009 at 1:08am
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.
|Go to Top|