Forums / Developer / fetch(tree [...] equivalent in PHP?

fetch(tree [...] equivalent in PHP?

Author Message

Gabriel Ambuehl

Monday 21 March 2005 8:45:51 am

Maybe I'm too tired or something, but I can't figure out how to fetch all children's of a given class of the same type (like one would do with fetch(tree... in tempaltes) in a custom module?

Visit http://triligon.org

Hans Melis

Tuesday 22 March 2005 12:09:36 am

Hi Gabriel

The content tree|list fetch uses the function eZContentObjectTreeNode::subTree( $params, $nodeID ).

The <i>$nodeID</i> is what you'd pass as parent_node_id in templates. <i>$params</i> is an associative array with the same parameters as in templates, except that you need to strip underscores and start all parts with a capital (ex: class_filter_array becomes ClassFilterArray).

hth

Hans
http://blog.hansmelis.be

Gabriel Ambuehl

Tuesday 22 March 2005 12:32:27 am

That is truly helpful. Thanks!

I thought it would probably be that function but couldn't figure out what I should be putting in that params array...

Visit http://triligon.org

Lex 007

Thursday 24 March 2005 3:29:31 am

hi,

I would like to fetch in PHP all the users from a given node (eg from a given group).

$children = eZContentObjectTreeNode::subTree( Array() , 12);

The function seems to work only for content objects, not users.

Could you help me ? thx

Gabriel Ambuehl

Thursday 24 March 2005 4:07:15 am

Users ARE content objects (in standard ezpublish anyway, there might be some configuration where this doesn't hold true). But you need to pass params like

	$tree=eZContentObjectTreeNode::subTree( array(	'ClassFilterArray' => array($class_id),
								'ClassFilterType' => 'include',
								'mainNodeOnly' => true),
							$parent_node_id ) ;
		

Visit http://triligon.org

Lex 007

Thursday 24 March 2005 4:24:35 am

Thx for your answer.

However, this only works for objects of the "content section", not the "users section". Any hint ?

Lex

Gabriel Ambuehl

Thursday 24 March 2005 4:41:56 am

What did you set as parent_node_id?

Visit http://triligon.org

Lex 007

Thursday 24 March 2005 5:29:24 am

12, that is the default user placement.

Gabriel Ambuehl

Thursday 24 March 2005 5:35:35 am

Weird, in my installation it's 5.

Well, I've run out of ideas...

Visit http://triligon.org

Lex 007

Thursday 24 March 2005 5:45:54 am

Finally, I used this query ... and it works. I really find it hard to work with eZ Publish objects and classes !

$sql = "SELECT 
	ezcontentobject.*,
	ezcontentobject_tree.*,
	ezcontentclass.name as class_name,
	ezcontentclass.identifier as class_identifier,
	ezcontentobject_name.name as name,  
	ezcontentobject_name.real_translation
FROM
	ezcontentobject_tree,
	ezcontentobject,
    ezcontentclass,
	ezcontentobject_name
WHERE
    path_string like '/1/5/".$node_id."/%' and  depth <= 7 
AND
	ezcontentclass.version=0 
AND
	node_id != ".$node_id." 
AND
	ezcontentobject_tree.contentobject_id = ezcontentobject.id
AND
	ezcontentclass.id = ezcontentobject.contentclass_id 
AND
	ezcontentobject.contentclass_id  IN  ( 4 ) 
AND
	ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id 
AND 
	ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version                 
AND 
    ezcontentobject_name.content_translation = 'eng-GB'
AND 
	ezcontentobject_tree.is_invisible = 0
AND 
	ezcontentobject.section_id in ( 1, 2, 11, 18, 20, 24, 25, 8)";

Gabriel Ambuehl

Thursday 24 March 2005 5:50:35 am

Yeah it's not exactly straight forward. But once you get the hang out of it, it's pretty powerful.

Now, if 4.0 would implement proper ORM à la Hibernate, that would be SWEET!

Visit http://triligon.org

Lex 007

Thursday 24 March 2005 6:20:38 am

"franglais" speaking ? ;)

eZ debug

Timing: Jan 20 2025 01:05:40
Script start
Timing: Jan 20 2025 01:05:40
Module start 'content'
Timing: Jan 20 2025 01:05:40
Module end 'content'
Timing: Jan 20 2025 01:05:40
Script end

Main resources:

Total runtime0.2204 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 588.9531180.8359
Module start 'content' 0.00660.0052 769.7891105.9141
Module end 'content' 0.01180.2085 875.7031533.7969
Script end 0.2203  1,409.5000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.5510200.0002
Check MTime0.00140.6305200.0001
Mysql Total
Database connection0.00080.357110.0008
Mysqli_queries0.171877.96071410.0012
Looping result0.00140.62711390.0000
Template Total0.208194.410.2081
Template load0.00080.384310.0008
Template processing0.207294.038910.2072
Override
Cache load0.00060.264110.0006
Sytem overhead
Fetch class attribute can translate value0.00130.593910.0013
XML
Image XML parsing0.00040.162910.0004
General
dbfile0.00743.3508200.0004
String conversion0.00000.002230.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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