Forums / Setup & design / How to show the relative objects in template?

How to show the relative objects in template?

Author Message

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

Quynh Nguyen

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 ezpublish, 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!

eZ debug

Timing: Jan 30 2025 21:35:43
Script start
Timing: Jan 30 2025 21:35:43
Module start 'content'
Timing: Jan 30 2025 21:35:43
Module end 'content'
Timing: Jan 30 2025 21:35:43
Script end

Main resources:

Total runtime0.2023 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 588.0625370.2734
Module start 'content' 0.00810.0154 958.33591,001.7031
Module end 'content' 0.02350.1787 1,960.03913,890.5391
Script end 0.2022  5,850.5781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00422.0823200.0002
Check MTime0.00130.6541200.0001
Mysql Total
Database connection0.00070.347610.0007
Mysqli_queries0.108653.68801410.0008
Looping result0.00140.71111390.0000
Template Total0.178388.110.1783
Template load0.00080.416210.0008
Template processing0.177487.696610.1774
Override
Cache load0.00060.284810.0006
Sytem overhead
Fetch class attribute can translate value0.00200.991610.0020
XML
Image XML parsing0.00030.141310.0003
General
dbfile0.00492.4453200.0002
String conversion0.00000.003130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs