Fetch By Attribute Value

Author Message

Carlos Revillo

Thursday 01 June 2006 6:32:13 am

Hi. Now i'm working with a extension and i need to write php code to fetch nodes by one of their attributes.

i can't find a method in the documentation for that.

i'm searching for something like eZContentObjectTreeNode::fetchNodesByPathString, but i can't find anything...

any ideas?

Kristof Coomans

Thursday 01 June 2006 11:34:12 pm

Hi Carlos

You can use something like

include_once( 'lib/ezutils/classes/ezfunctionhandler.php' );
$nodes = eZFunctionHandler::execute('content','tree', $params );

where $params is an associative array with the same keys as you can use for the content/tree fetch function ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/tree ) in the templates. Then you can use the attribute_filter key to filter on attributes.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Carlos Revillo

Monday 05 June 2006 3:13:17 am

Great!. Works perfectly. Thanks a lot.

Montel Sébastien

Thursday 08 June 2006 8:58:46 am

Hi,

I try to manipulate the eZFunctionHandler class but it doesn't work. With eZContentObjectTreeNode, i fetch the nodes for example below node number 2.

include_once ('kernel/classes/ezcontentobjecttreenode.php');
$nodes =& eZContentObjectTreeNode::subTree(array('Depth'=>1),2);

To obtain the same result with eZFunctionHandler class, i use

include_once ('lib/ezutils/classes/ezfunctionhandler.php');
$nodes = eZFunctionHandler::execute('content','list', array('parent_node_id' => 2) );

But in this case, nothing in result. Where do i make a mistake ?

thanks,
Sébastien

Kristof Coomans

Thursday 08 June 2006 10:28:58 am

What exactly do you get back?

var_dump( $nodes );

Do you get any PHP errors/warnings in the debug output?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Łukasz Serwatka

Thursday 08 June 2006 2:04:13 pm

Hmm, I think you were testing the fetch from the CLI script, right? ;)

Then you need to tell script to use modules:

replace line:

$script =& eZScript::instance();

with:

$script =& eZScript::instance( array( 'use-modules' => true ) );

Then it will work.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Montel Sébastien

Thursday 08 June 2006 11:38:30 pm

Hi Lukasz,

you're right, i want to fetch data from the CLI script ... your help was useful ! it works ... (thanks a lot for your article "about Fetching eZ publish content objects with PHP", it's nice to understand kernel ... :-) )

merci !

Sébastien

Łukasz Serwatka

Thursday 08 June 2006 11:59:42 pm

You are welcome Sébastien ;) I have posted comment about this under the tutorial for future readers.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

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 18 2025 18:41:09
Script start
Timing: Jan 18 2025 18:41:09
Module start 'layout'
Timing: Jan 18 2025 18:41:09
Module start 'content'
Timing: Jan 18 2025 18:41:10
Module end 'content'
Timing: Jan 18 2025 18:41:10
Script end

Main resources:

Total runtime0.7252 sec
Peak memory usage4,096.0000 KB
Database Queries76

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 587.9063152.6250
Module start 'layout' 0.00450.0027 740.531339.4297
Module start 'content' 0.00720.7165 779.9609675.0859
Module end 'content' 0.72360.0015 1,455.046916.1797
Script end 0.7251  1,471.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4269160.0002
Check MTime0.00140.1949160.0001
Mysql Total
Database connection0.00060.082110.0006
Mysqli_queries0.652489.9609760.0086
Looping result0.00090.1246740.0000
Template Total0.694495.820.3472
Template load0.00230.313720.0011
Template processing0.692195.446520.3461
Template load and register function0.00080.104310.0008
states
state_id_array0.00090.130710.0009
state_identifier_array0.00120.160820.0006
Override
Cache load0.00200.2760460.0000
Sytem overhead
Fetch class attribute can translate value0.00100.133640.0002
Fetch class attribute name0.00090.1214100.0001
XML
Image XML parsing0.00150.209240.0004
class_abstraction
Instantiating content class attribute0.00000.0036120.0000
General
dbfile0.00080.1150240.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs