This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » fetch sort_by conditional

fetch sort_by conditional

fetch sort_by conditional

Saturday 01 November 2003 1:28:11 pm - 5 replies

Hi all,
I am trying to fetch data with a conditional in it, but can't work out the sort_by syntax...

I am trying to do this:

Fetch all children of a certain node of a certain class where the value of item.data_map.year.data_int > 2002.

Any ideas?


Saturday 01 November 2003 1:39:50 pm

Have a read of this doco:


Saturday 01 November 2003 2:06:09 pm

Thanks for the reply.

I actually looked at that page before posting. I am afraid, it didn't clear up my confusion:

Here is what I am trying to do:
Fetch all children of node 47 of class 19 where the value of item.data_map.year.data_int > 2002.

fetch( content, list, hash(
parent_node_id, 47,
limit, 3,
sort_by, array( priority, false() ),
class_filter_type, include,
class_filter_array, array( 19 )
attribute_filter( 19, '>', 2002) ) )}

now I assume the attribute_filter() syntax is incorrect, but I am not sure how to get the fetch to match against values in the children nodes...

Any pointers would be much appreciated.


Saturday 01 November 2003 2:30:22 pm

The problem is likely with your use of the class attribute id. You have:

attribute_filter( 19, '>', 2002)

where it is seems 19 is the class id. but if you look at the doco again this parameter needs to the class attribute id.

What you need to do is look at your class again in the admin and identify the id number for your 'year' attribute. Put this number in your fetch and see if this works.

Btw, do you have debug on? It may be reporting this error.


Saturday 01 November 2003 5:26:08 pm

Quite rightly, the docos specify the class attribute id.

In my admin section it reports that my class attribute id is 171:
Year (Integer) (id:171)

so, i modified to suit this:
{let news_list=fetch( content, list, hash(
parent_node_id, 47,
sort_by, array( array( published, false() ) ),
attribute_filter, array('or', array(171, '>=', 2003) ) ) )}

and presto it works! My syntax and my id were wrong.

What makes little sense to me is the need for the "array('or', ...)" part in the syntax, but it works and for the moment that is good enough.

Thanks for the help again!

Sunday 02 November 2003 2:07:22 pm

Glad it worked happy.gif Emoticon

The use of 'array' is just a way of passing the variables from the template language to the underlying php. i think by using an array all the parameters are passed in with a single variable. this helps keep the api interface a little simpler.



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

36 542 Users on board!

Forums menu

Proudly Developed with from