Forums / Setup & design / How to sort arrays of ez content objects?

"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".

How to sort arrays of ez content objects?

Author Message

Daniele Nocentini

Tuesday 16 September 2008 8:02:54 am

Hi,
I want to sort array of ez content objects by the object name. The problem is that I'm not getting them with a fetch which would sort them properly because I need to create custom array that contain some ez content object.

Does anyone know a good solution?

Antica Bottega Digitale srl
http://www.abd.it

Paul Etienney

Wednesday 17 September 2008 4:16:17 am

I have the same question.
+1

-- Good websites creation --
My site : http://www.pauletienney.com
Twitter : http://www.twitter.com/p_etienney

Andreas Adelsberger

Wednesday 17 September 2008 4:29:18 am

You can create a new hash array and sort it afterwards using an extension:

http://ez.no/developer/contribs/template_plugins/arraysortoperator

...untested...

{def $new_array = array()} 
{foreach $children as $child}
		{set $new_array=$new_array|append(hash('name',$child.name,'ezobject',$child))}
{/foreach}

{set $new_array=$new_array|sort}

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.

Daniele Nocentini

Wednesday 17 September 2008 7:44:15 am

Thanks Andreas for your solution it's great and work fine for my project, only one thing I have declared variable as an array:

{def $new_array = array()}

Antica Bottega Digitale srl
http://www.abd.it

Andreas Adelsberger

Wednesday 17 September 2008 7:46:46 am

You are welcome. I fixed it in the code above.

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.