eZ Community » Forums » Developer » Fetching nodes by attribute content
expandshrink

Fetching nodes by attribute content

Fetching nodes by attribute content

Tuesday 05 July 2011 6:24:39 pm - 2 replies

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.

Wednesday 06 July 2011 12:07:34 am

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 );

Thursday 07 July 2011 3:17:54 pm

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.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from