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 15 2025 06:54:20
Script start
Timing: Jan 15 2025 06:54:20
Module start 'content'
Timing: Jan 15 2025 06:54:21
Module end 'content'
Timing: Jan 15 2025 06:54:21
Script end

Main resources:

Total runtime1.4163 sec
Peak memory usage6,144.0000 KB
Database Queries216

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 684.1484214.7969
Module start 'content' 0.00601.2756 898.94531,944.5156
Module end 'content' 1.28170.1346 2,843.4609642.8594
Script end 1.4162  3,486.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00700.4910210.0003
Check MTime0.00140.1007210.0001
Mysql Total
Database connection0.00070.046510.0007
Mysqli_queries1.303292.01322160.0060
Looping result0.00190.13482130.0000
Template Total1.380797.520.6903
Template load0.00430.305520.0022
Template processing1.376497.180820.6882
Template load and register function0.00120.085610.0012
states
state_id_array0.00150.108010.0015
state_identifier_array0.00100.070020.0005
Override
Cache load0.00400.2825460.0001
Sytem overhead
Fetch class attribute can translate value0.00110.080140.0003
Fetch class attribute name0.00180.1261140.0001
XML
Image XML parsing0.00600.423140.0015
class_abstraction
Instantiating content class attribute0.00000.0022180.0000
General
dbfile0.00710.5003260.0003
String conversion0.00000.000630.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
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 6

Time used to render debug report: 0.0002 secs