eZ Community » Forums » Setup & design » Fetch only object with a...

Fetch only object with a checkbox-attribute enabled?

Fetch only object with a checkbox-attribute enabled?

Saturday 27 May 2006 8:48:13 pm - 4 replies


I have a class with a checkbox attribute. I want to fetch only nodes with this checkbox enabled. This would be my guess, but I'm not able to get it work:

fetch  ( content  , list  , hash  ( parent_node_id , $node.node_id , attribute_filter , array ( array ( 224 , = ,1 ) ) ) ) }

224 is the attribute (checkbox) id.

Frode S.

Saturday 27 May 2006 9:22:37 pm

Hi Frode

try with:

fetch( content, list, hash( parent_node_id, $node.node_id, attribute_filter, array( array( 224, '=', '1' ) ) ) ) }

spaces and single quotes are important

Saturday 27 May 2006 11:50:17 pm


Thanks a lot for a quick and good answer. The spaces in my template didn't look like this i posted here but after I did like you said it works happy.gif Emoticon Thanks a lot!

Didn't really know that spaces and quotes was that important...


Monday 29 May 2006 2:23:42 pm

Spaces are irrelevant, but the quotes around = are necessary, and they can be either single or double quotes, as long as they match.
You should technically quote all keys in a hash, since they are supposed to be strings. PHP and the eZ publish template language automatically convert identifiers that start with an alphabetical character to a string. This behaviour promotes sloppy coding, but it's easy so nobody complains about it.
In the case of the = character, which is not alphabetic, this conversion is not done automaticallay, that's why you have to quote it.
The manual specifies all functions with quoted identifiers, by the way. Like fetch('content', 'list', etc.), this is how it should be done. Read the manual!

Monday 29 May 2006 2:49:54 pm

Spaces are irrelevant

Spaces are irrelevant when used between the parameters of a template operator, but they shouldn't be used between a template operator and it's opening parenthesis.

Not right:

fetch ( ... )


fetch( ... )

This rule is also valid for <i>hash</i> and <i>array</i> (they are template operators too), as you can see in post 1 and 2 of this topic.


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

36 542 Users on board!

Forums menu

Proudly Developed with from