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