Forums / Developer / Fetching nodes by attribute content

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

Fetching nodes by attribute content

Author Message

Sao Tavi

Tuesday 05 July 2011 9:24:39 am

This should be simple, but I cannot find the function.

So, I need to fetch all the nodes of a specific class, that descend from a specific node and that have some attribute content equal to some value. It should be something like a search with these criteria.

Steven E. Bailey

Tuesday 05 July 2011 3:07:34 pm

API or template?

If it's template you have to do something like this:

 {def $items=fetch( content, tree, hash( parent_node_id, $topNodeID, attribute_filter, array( 'and', array( $identifier,'like',$char.'*'),array( 'profile/staff ,'!=', 2 ), array( 'profile/staff ,'!=', 0 )) ))}

*Not tested - variables changed to match the php code - no idea if this will work in this form - but it should give you the idea.

If it's the API you have to do something like this:

$attributefilter[]= 'and';
 $attributefilter[]= array( $identifier,'like',mysql_escape_string($char).'*');
 $attributefilter[]= array( 'profile/staff ,'!=', 2 );
 $attributefilter[]= array( 'profile/stafff' ,'!=', 0 );

$params['AttributeFilter']              = ($attributefilter);

$output = eZContentObjectTreeNode::subTreeByNodeID( $params, $topNodeID );

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Marko Žmak

Thursday 07 July 2011 6:17:54 am

Sao, for the complete documentation of the templat fetch function look here:

As for the "documentation" for the API you should inspect the code of subTreeByNodeID() function:

Also, note that attribute filtering can have an impact on site performance (it produces complex and consuming sql queries), and should be used with caution.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth