Forums / Developer / Sorting by multiple attributes

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Sorting by multiple attributes

Author Message

Albert Calmus

Wednesday 24 August 2011 7:27:51 am

Hello,

I use tree fetch function and I would sort by multiples attributes.
This means I have a syntax like this :

'sort_by', array(

array('attribute', false(), 'new_item/creation_date'),
array('attribute', false(), 'old_item/creation_date'),

)

It doesn't work and I don't find the solution in the doc :
http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list

The fact that we cannot use the same sort method many times is written anywhere.

Thanks in advance !

Håvard Bergersen

Wednesday 24 August 2011 7:42:54 am

Is is the sorting that doesn't work, or does the whole fetch break?

Looks like you have a comma to much: 'old_item/creation_date'), <-

(Don't know if this i enough to break it but, worth a shot?)

 

 

EDIT:

I don't think you can sort on two different classes....?

Edi Modrić

Wednesday 24 August 2011 7:57:00 am

Havard is right, you cannot use attribute sorting if your fetch returns objects of multiple classes.

eZ Publish certified developer

http://ez.no/certification/verify/350658

Tyler Harms

Wednesday 24 August 2011 9:59:35 am

Instead have you tried using the .sortarray?

'sort_by', $your_node_parent.sort_array

That way the admin can control how items are sorted.