This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Global variable in a template

Global variable in a template

Global variable in a template

Friday 29 January 2010 2:59:38 am - 1 reply

Hi, I have a template for the xml view of a object. For example:


<title>{attribute_view_gui attribute=$articleNode.data_map.title}</title>
<byline>{attribute_view_gui attribute=$articleNode.data_map.byline}</byline>
<image>{attribute_view_gui attribute=$articleNode.data_map.image}</image>


On this page, I have 2 nested 'for' loops that contain a value within that needs to be displayed once these loops are done with their output.


{foreach $node.data_map.selection.content as $obj_relations}
{foreach $obj_relations as $item}





Value is : {$value}


The problem is that I'm getting a empty variable. I tried defining this variable outside the loop with {def $value='test'} and then setting it inside the loop but just end up with 'test'. Is there any way to set this variable when inside the loop?


Friday 29 January 2010 11:02:49 am

You should use the set template operator to modify an existing variable (def works too, but is not logical as far your variable has been already declared) :

{set $value = "your value"}

Documentation page :

Modified on Friday 29 January 2010 11:03:35 am by Damien MARTIN


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

36 542 Users on board!

Forums menu

Proudly Developed with from