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 ? ;)

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 19:07:38
Script start
Timing: Jan 18 2025 19:07:38
Module start 'layout'
Timing: Jan 18 2025 19:07:38
Module start 'content'
Timing: Jan 18 2025 19:07:39
Module end 'content'
Timing: Jan 18 2025 19:07:39
Script end

Main resources:

Total runtime0.7262 sec
Peak memory usage4,096.0000 KB
Database Queries86

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.1875152.6250
Module start 'layout' 0.00760.0029 741.812539.4453
Module start 'content' 0.01050.7143 781.2578668.5625
Module end 'content' 0.72480.0013 1,449.820324.1563
Script end 0.7262  1,473.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4622160.0002
Check MTime0.00130.1827160.0001
Mysql Total
Database connection0.00090.119810.0009
Mysqli_queries0.653790.0069860.0076
Looping result0.00070.1018840.0000
Template Total0.692695.420.3463
Template load0.00240.324720.0012
Template processing0.690395.049520.3451
Template load and register function0.00010.017610.0001
states
state_id_array0.00080.110010.0008
state_identifier_array0.00090.125720.0005
Override
Cache load0.00200.2799460.0000
Sytem overhead
Fetch class attribute can translate value0.00050.065430.0002
Fetch class attribute name0.00130.1817140.0001
XML
Image XML parsing0.00230.315330.0008
class_abstraction
Instantiating content class attribute0.00000.0046180.0000
General
dbfile0.00280.3903210.0001
String conversion0.00000.000840.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
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
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: 6

Time used to render debug report: 0.0002 secs