eZ Community » Forums » Developer » Sort related objects by order
expandshrink

Sort related objects by order

Sort related objects by order

Monday 28 October 2013 2:44:54 pm - 1 reply

Hi there,

On the front end I'm trying to sort my related objects by the order in which they appear in the back office. It is the field on the right called 'ordre' in French in which we can enter numerals to manage the order.

I have tried using sort by priority and order, but to no avail.

 

Here is the code :

{def $my_node = fetch( 'content', 'related_objects', hash( 'object_id', $obj_id, 'attribute_identifier', 361, 'sort_by', array( 'priority', true() ) ) )}

I'll buy a beer for anybody who can show me the solution blunk.gif Emoticon

 

Thanks

Andy

Tuesday 29 October 2013 11:59:55 am

Hi, Andy.

This is actually not possible to do with a relation fetch. Instead, you can solve it with some code like this:

 {foreach $node.data_map.relations_attribute.content.relation_list as $relation}
    {set $related_node = fetch( 'content', 'node', hash( 'node_id', $relation.node_id ) )}
    ...do something cool...
{/foreach}

 

I'll be making a note of that beer. happy.gif Emoticon

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from