Forums / Developer / Fetch path_array directly in PHP

Fetch path_array directly in PHP

Author Message

Damien MARTIN

Moderated by: Nicolas Pastorino

Tuesday 19 January 2010 2:45:17 am

Hi there,

I would like to know how to fetch the path_array of a node from PHP.

I tried something like this :

$object = eZContentObject::fetchByNodeID($node_id);
$url = $object->attribute("path_array");

or

$path = new eZPathElement(array("id" => $node_id));
$path_array = $path->getPathArray();

But I still not able to get the path_array for a defined node_id.

Could someone help me ?

Thanks,

Damien

Jarosław Heba

Tuesday 19 January 2010 5:31:40 am

You should fetch a node - not an object.

Try this:

$mynode = eZContentObjectTreeNode::fetch( $node_id );

$my_path_array = $mynode->attribute( 'path_array' );

Please notice that you will get an array in $my_path_array - not URL.

Kind regards

J

Damien MARTIN

Tuesday 19 January 2010 5:38:28 am

Thank you very much Jarosław,

It works very well.