Forums / Setup & design / Can I use a value from one template in another template?
Ricardo Lindooren
Monday 05 May 2003 2:53:57 pm
Hello,
From a template/page I can create a new contentobject.I'm able to do this with the following code:
<form method="post" action="/Exponential/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="{$content_object.id}" /> <input class="button" type="submit" name="NewButton" value="Submit" /></form>
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’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?
Thanks,
Vivienne van Velzen
Tuesday 06 May 2003 1: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,
Vivienne
Tuesday 06 May 2003 3:49:40 am
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?