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

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

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:

<code>

<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>

</code>

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.

<code>

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

...

{$value}

{/foreach}

{/foreach}

Value is : {$value}

</code>

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?

thanks.

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 : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_functions/variables/set

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

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from