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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 13:34:42
Script start
Timing: Jan 29 2025 13:34:42
Module start 'layout'
Timing: Jan 29 2025 13:34:42
Module start 'content'
Timing: Jan 29 2025 13:34:42
Module end 'content'
Timing: Jan 29 2025 13:34:42
Script end

Main resources:

Total runtime0.0168 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.1563151.2109
Module start 'layout' 0.00530.0023 739.367236.6563
Module start 'content' 0.00760.0077 776.023490.7969
Module end 'content' 0.01530.0014 866.820333.9766
Script end 0.0167  900.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.9146140.0002
Check MTime0.00116.4528140.0001
Mysql Total
Database connection0.00084.947410.0008
Mysqli_queries0.002112.510030.0007
Looping result0.00000.059810.0000
Template Total0.00106.110.0010
Template load0.00084.618710.0008
Template processing0.00021.432810.0002
Override
Cache load0.00053.187310.0005
General
dbfile0.003017.713480.0004
String conversion0.00000.047040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs