Share » Forums » Developer » Extension : How to retrieve a node_id...

Extension : How to retrieve a node_id sort_array ?

Extension : How to retrieve a node_id sort_array ?

Tuesday 30 May 2006 4:26:47 am - 4 replies

Modified on Wednesday 31 May 2006 5:25:49 am by H-Works Agency

Author Message

Łukasz Serwatka

Thursday 01 June 2006 12:13:49 am

Hi,

You can get sort_array and node_id like:

include_once( 'kernel/classes/ezcontentobjecttreenode.php' );

// {def $node=fetch( 'content', 'node', hash( 'node_id', 2 ) )}
$node =& eZContentObjectTreeNode::fetch( 2 );

// {$node.node_id}
$node->attribute('node_id');

// {$node.sort_array}
$nodeSortArray =& $node->sortArray();
// {$node.parent.sort_array}
$parent =& $node->fetchParent();
$parentSortArray =& $parent->sortArray();

Hope it will help you.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

H-Works Agency

Thursday 01 June 2006 1:40:20 pm

Thanx Lukas, i am gonna try that.

But if i understand, if i want to only get a node sort_array i should use :

$node =& eZContentObjectTreeNode::fetch( 2 );
$nodeSortArray =& $node->sortArray();

Or do i have to include the following line inbetween :

$node->attribute('node_id');

Well i am gonna try anyway. Thanx a lot for your help.

Martin

EZP is Great

Łukasz Serwatka

Thursday 01 June 2006 1:47:21 pm

No, you don't need to put $node->attribute('node_id'); between. It was just an example how to get node id ;)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

H-Works Agency

Friday 02 June 2006 11:05:18 am

Ok thanx a lot...it works !

I finally use this code :

$node =& eZContentObjectTreeNode::fetch($node_id);
$sortBy =& $node->sortArray();
$sortBy = $sortBy[0];

I had to add '$sortBy = $sortBy[0];' otherwise it output 'array(array('published',false))' and not just 'array('published',false)' as needed.

Martin

EZP is Great

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu