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 » Setup & design » Can I use a value from one template...

Can I use a value from one template in another template?

Can I use a value from one template in another template?

Monday 05 May 2003 11:53:57 pm - 2 replies


From a template/page I can create a new contentobject.
I'm able to do this with the following code:

<form method="post" action="/ezpublish/index.php/demo/content/action/">
<input type="hidden" name="NodeID" value="{$node.node_id}" />
<input type="hidden" name="ClassID" value="29" />
<input type="hidden" name="ContentObjectID" value="{$}" />
<input class="button" type="submit" name="NewButton" value="Submit" />

I have created a file called 'edit_class_29.tpl' with the correct code and this all works fine.

But I have a question;

On the page with the submit button (see the form-code above) I have a value that I would like to use in the edit-template 'edit_class_29.tpl'.

I have tried to create a hidden field which is also being submitted:
<input type="hidden" name="Testvalue" value="1234" />

But unfortunately I cannot use this value in my edit-template. {$Testvalue} results in: Unknown template variable ' Testvalue ' in namespace ''

I&#8217;ve tried to create a cookie with JavaScript containing the value. But when I use this solution I loose my Session-ID.

Can somebody tell me how I can get a value from one template to another?


Ricardo Lindooren

Tuesday 06 May 2003 10:22:01 am

You can pass a value from one template to the other like this:

{* I'm in first.tpl, calling a view second.tpl *}
{node_view_gui view=second content_node=$node myvalue=$myvalue}
{* /calling *}

Now you can use the variable myvalue in second.tpl.
Hope this helps,


Tuesday 06 May 2003 12:49:40 pm

Vivienne, thank you very much for your help.

Your solution does answer my question, but unfortunately I can't use it.
In my case the second template is opened after clicking on the 'form submit button'.

That's also the reason why I tried to pass my value trough a hidden form field.

Can you (or someone else) tell me if this is possible?


Ricardo Lindooren

Modified on Tuesday 06 May 2003 12:50:46 pm by Ricardo Lindooren


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

36 542 Users on board!

Forums menu

Proudly Developed with from