Forums / Developer / children id list

children id list

Author Message

Aladdin Mouhaimeed

Tuesday 13 September 2005 7:58:06 am

How can I have a list of IDs of the node's children in PHP (not in template language)????
I know this will be so simple, but I tried hard.

Aladdin Mouhaimeed

Tuesday 13 September 2005 9:53:03 am

Hi :
i have used this code for doing that:

$var = call_user_func_array( array( new eZContentFunctionCollection(), 'fetchObjectTree' ),
array('parent_node_id' => 59,
'only_translated' => false,
'language' => false,
'offset' => false,
'limit' => false,
'depth' => 100,
'depth_operator' => "le",
'class_id' => false,
'attribute_filter' => false,
'extended_attribute_filter' => false,
'class_filter_type' => false,
'class_filter_array' => false,
'group_by' => false,
'main_node_only' => false,
'ignore_visibility' => false,
'limitation' => null,
'as_object' => null ) );
$var = isset( $var['result'] ) ? $var['result'] : null;
echo $var;
while ( is_object( $var ) and method_exists( $var, 'templateValue' ) );
$v= $var[1];
echo $v->attribute('node_id');

and that makes us getting the ids of children nodes, so is it good way?or there is cleaner one?

Aladdin Mouhaimeed

Tuesday 13 September 2005 11:21:46 am

Well Aladdin, you ask for help, I'm here to help.

use this code from http://ez.no/community/forum/developer/moving_objects_via_php_cron/re_moving_objects_via_php_cron__23

        $existingNode = $object->attribute( 'main_node' );
		$folder_node_id = $existingNode->attribute( 'node_id' );
	    $childNodes =& eZContentObjectTreeNode::subTree( $params, $folder_node_id );
    foreach( $childNodes as $child )
    {
        $thisNode = $child -> MainNodeID;
        $userID = $child -> ContentObjectID;
echo $thisNode;
       // Fetch the user object
       $object =& eZContentObject::fetch( $userID );

  }

Bertrand Dunogier

Tuesday 13 September 2005 12:32:03 pm

$node =& eZContentObjectTreeNode::fetch($nodeID);
$children =& $node->children();
foreach ( array_keys( $children ) as $key )
{
  $ids[] = $children[$key]->NodeID;
}

There you are.