Forums / Setup & design / How to show the relative objects in template?
Quynh Nguyen
Saturday 21 March 2009 3:44:15 am
I used this datatype in my class: eZObjectrelationbrowse - http://ez.no/developer/contribs/datatypes/ezobjectrelationbrowse_datatype
But I don't know how to display the link list in template.
I use attribute(show) and get only node_id list:
{foreach $node.data_map.relative_objects.content.relation_browse as $obj} NODE_ID: {$obj.node_id}<br /> {/foreach}
I can fetch data: name and link of each node by using:
{foreach $node.data_map.relative_objects.content.relation_browse as $obj} {def $my_node=fetch( 'content', 'node', hash( 'node_id', $obj.node_id ) )} <a href={$my_node.url_alias|ezurl}>{$my_node.name|wash}</a> {undef $my_node} {/foreach}
but I don't think that this is the best way to do.
In technical manual talked about ezobject and eznode. But I don't know how to use.
Please help me!
justin kazadi
Monday 23 March 2009 1:00:58 am
Hi,you don(t have access to the attribute
url_alias
of an object relation so you have to use the main node.so use this:
{foreach $node.data_map.relative_objects.content.relation_browse as $obj} <a href={$obj.main_node.url_alias|ezurl}>{$obj.name|wash()}</a> {/foreach}
i think this can help you.
good luck
The theory is when we know everything and nothing works. The practice is when everything works and nobody knows why. If the practice and theory are met, nothing works and we do not know why. Albert Einstein
Monday 23 March 2009 1:11:55 pm
Hi Justin,
This is the attribute of each $obj
Attribute Type Value identifier boolean false priority string '9' in_trash boolean false contentobject_id string '892' contentobject_version string '2' node_id string '868' parent_node_id string '124' contentclass_id string '45' contentclass_identifier string 'news' is_modified boolean false contentobject_remote_id string 'cf51ae7844a791ca07c2aaff667d73c9'
So I think there is no attribute main_node as you talked.
Because in Exponential, we can link to eznode or ezobject. But it can be done in XML Block datatype (as when we compose content). The relatived objects are another datatype. I can use my method at the moment, but I'm looking for another better way.
Thanks you anyway!