Forums / General / Fetch By Attribute Value

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

eZ debug

Timing: Jan 18 2025 14:52:15
Script start
Timing: Jan 18 2025 14:52:15
Module start 'content'
Timing: Jan 18 2025 14:52:16
Module end 'content'
Timing: Jan 18 2025 14:52:16
Script end

Main resources:

Total runtime1.0538 sec
Peak memory usage4,096.0000 KB
Database Queries213

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 587.6875180.8438
Module start 'content' 0.00710.8935 768.5313680.1641
Module end 'content' 0.90060.1531 1,448.6953340.4609
Script end 1.0537  1,789.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.4497210.0002
Check MTime0.00200.1917210.0001
Mysql Total
Database connection0.00110.100910.0011
Mysqli_queries0.964191.49122130.0045
Looping result0.00270.25752110.0000
Template Total1.014196.220.5071
Template load0.00240.227820.0012
Template processing1.011796.010920.5059
Template load and register function0.00020.014710.0002
states
state_id_array0.00100.091610.0010
state_identifier_array0.00240.232020.0012
Override
Cache load0.00220.2041460.0000
Sytem overhead
Fetch class attribute can translate value0.00150.144450.0003
Fetch class attribute name0.00230.2177100.0002
XML
Image XML parsing0.00460.440550.0009
class_abstraction
Instantiating content class attribute0.00000.0026120.0000
General
dbfile0.00470.4505350.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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