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 » General » attribute_filter: needs more explanation

attribute_filter: needs more explanation

attribute_filter: needs more explanation

Friday 19 September 2003 4:01:09 pm - 4 replies

Hi guys,

I have a fetch(content, list,..) which correctly gets all the objects I want it to get, now I want to limit the result with attribute_filter.

First problem: I do not get it work with one argument only, like:
attribute_filter, array( 159, '=', 'aValue' )

it doesn't seem to be the correct syntax, any other is not intuitive for me and there's no example with only one argument, so I use the example I found:

array( 'or', array( 159, '=', 'aValue'' ), array( 156, '=', 'foobar' ))

attribute_id 156 is valid, but does o.c not contain foobar, it's an 'or' combination, so it shouldn't matter.

Now, take for granted, there is a attribute_id 159, it's a text line datatype, and be asured, there is an (published) object with a corresponding value 'aValue'!

I don't get it to fetch anything, no errors, no output.

I don't know where to start to look for the problem! Did I misunderstand anything?

Thanks very much for help!

Modified on Tuesday 23 September 2003 1:46:33 pm by Thomas Brandl

Tuesday 23 September 2003 2:17:27 pm

I had some problems with it too. But after some trial and error I found how it works.

If you want to filter only on one parameter just leave out the third parameter. It would look like this: array('or', array(156, '=', 'foobar'))

If you don't see anything appearing that could be lots of things. My advice -- first try a fetch without attribute_filter and if that's working -> start filtering.

Also check if you clear the cache entirely. There is a little mistake of the eZ crew in the clear cache script in 3.2 stable. Consult this thread:



Tuesday 23 September 2003 3:20:54 pm

Hi Tom,

fetch without filtering is no problem, did not get any further.

Do you have a working example for me, maybe the problem lies somewhere else and I'm to blind to see!?

Tuesday 23 September 2003 4:23:19 pm

found this:
eZ is trying to find the value i'm looking for in ezcontentobject_attribute.sort_key_string:
... ( a0.sort_key_string = 'aValue' ) ...

This field is empty for all my records!

Besides, I don't understand it: If I'd decide to filter on some other attribute tomorrow, how should this value find its way into sort_key_String or sort_key_int?? Should't the field to search in depend solely on the datatype used for the attribute in question - data_text, data_int or data_float?

Thanks for enlightment

Wednesday 24 September 2003 9:51:14 am

The following code works for me:

{let folder_list=fetch( content, list, hash( parent_node_id, 2, sort_by, array( array( priority ) ),
attribute_filter, array('or', array(152, '=', '0')))) }

{section name=Folder loop=$folder_list}
<td class="topmenu">
<a href={concat( "/content/view/full/", $Folder:item.node_id, "/" )|ezurl}>{$|wash}</a>

2 remarks:

About the no errors thing -> Is debug enabled on your site? If not switch it to enabled in site.ini

Are you using version 3.2 stable, in previous versions there was a bug that generated a wrong query?


Modified on Wednesday 24 September 2003 10:18:42 am by Tom Couwberghs


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

36 542 Users on board!

Forums menu

Proudly Developed with from