Author Topic

Bertrand Dunogier

Thursday 15 April 2010 7:18:38 am

Comment58459

If you know how to get the info using the template engine, you can easily get it using PHP, using the attribute() method.

First, a small correction: your attribute will contain a link to an object, not a link to a node. That's why it's called object relation, and not node relation ;)

Now, for the actual question, the first pieces of your code are alright. Once you know what the content() method of an ezcontentobjectattribute of type 'object relation' returns, you're almost done. According to http://ez.no/doc/ez_publish/technical_manual/4_x/reference/datatypes/object_relation, in the "Raw output" chapter, .content on such an attribute returns the eZContentObject. All you need is the node for this object. The easiest way is to request the main node. Once you have it, you can easily get its name:

$userLink = $userMap['userLink']->content();
$node = $userLink->attribute( 'main_node' );
$nodeName = $node->attribute( 'name' );

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier