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

Author Message

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="/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="{$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&#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?

Thanks,

Ricardo Lindooren

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

Ricardo Lindooren

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?

Thanks,

Ricardo Lindooren

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:25:13
Script start
Timing: Jan 18 2025 04:25:13
Module start 'layout'
Timing: Jan 18 2025 04:25:13
Module start 'content'
Timing: Jan 18 2025 04:25:14
Module end 'content'
Timing: Jan 18 2025 04:25:14
Script end

Main resources:

Total runtime0.6841 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.1563152.6563
Module start 'layout' 0.00550.0034 740.812539.5078
Module start 'content' 0.00890.6736 780.3203476.6484
Module end 'content' 0.68250.0016 1,256.968812.0938
Script end 0.6840  1,269.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.5195160.0002
Check MTime0.00140.2083160.0001
Mysql Total
Database connection0.00070.108510.0007
Mysqli_queries0.627791.7565570.0110
Looping result0.00090.1276550.0000
Template Total0.648894.820.3244
Template load0.00220.322820.0011
Template processing0.646694.524520.3233
Template load and register function0.00010.020310.0001
states
state_id_array0.00160.233010.0016
state_identifier_array0.00120.170720.0006
Override
Cache load0.00190.2797380.0001
Sytem overhead
Fetch class attribute can translate value0.00050.073720.0003
Fetch class attribute name0.00140.202530.0005
XML
Image XML parsing0.00060.091220.0003
class_abstraction
Instantiating content class attribute0.00000.001630.0000
General
dbfile0.00070.1031100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs