Forums / Developer / sort_by attribute and attribute type

sort_by attribute and attribute type

Author Message

Jean-Luc Nguyen

Wednesday 17 December 2008 2:47:40 am

Hello,

I made a fetch:

{set $ideas = fetch( 'content', 'list', hash(	'parent_node_id', 2,
                                'class_filter_type', 'include',
                                'class_filter_array', array( 'idea' ),
                                'sort_by', array( 'attribute', false(), 'idea/vote' ) ) )}

The "vote" attribute is an integer datatype, but the $idees array is not sorted by votes.
When I change to this:

{set $ideas = fetch( 'content', 'list', hash(	'parent_node_id', 2,
                                'class_filter_type', 'include',
                                'class_filter_array', array( 'idea' ),
                                'sort_by', array( 'attribute', false(), 'idea/title' ) ) )}

The "title" attribute is a line of text datatype, the $idees is correctly alphabetically sorted.

My question is idiot but we can sort by integer, right? I get nothing wrong on my debug...
Thanks a lot!

http://www.acidre.com

Stéphane Bullier

Wednesday 17 December 2008 12:37:20 pm

Hello Jean-Luc,

I test your example of sort on some content object of my project and it's working : the greater vote is in first. Strange ?

If you look here http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list integer datatype is supported with sorting on the attribute level.

Cheers.

Stéphane

Jean-Luc Nguyen

Thursday 18 December 2008 2:26:37 am

Yes, that is weird... I am going to investigate then, thanks a lot!

http://www.acidre.com

Thiago Campos Viana

Friday 20 March 2009 12:49:39 pm

if u are updating the attribute vote by sql, u have to update the field sort_key_int of the table ezcontentobject_attribute, it's something like this:

$l_STR_Requete = "UPDATE ezcontentobject_attribute
SET data_int = \"".$l_INT_Nb."\", sort_key_int = \"".$l_INT_Nb."\"
WHERE version = \"".$l_TAB_Resul[0]['version']."\"
AND id =\"".$l_TAB_Resul[0]['id']."\" ;";

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br