Forums / Setup & design / Variable visibility through templates
Stefano Guandalini
Wednesday 14 June 2006 1:39:29 am
I just want to be sure a template is loaded only once in a page but if, for example, I include a template into itself, also all templates included by this template are recurrently loaded.I tried to track this using a simple trick (this code for example is in column1.tpl):
{if is_set( $loaded )|not()} {def $loaded=true} {include uri='design:column1.tpl'} {/if}
but is seems that <i>visibility</i> of $loaded variable is limited to this template and when it is reloaded it <i>is_set</i> no more.
Any suggestion?
Bye
g
Stefano Guandalini http://www.nizan.net
Thursday 15 June 2006 8:40:44 am
HEEEEEEEELP!
I really cannot understand why it works (but it works).
This one:
{set-block scope=global variable=loaded}true{/set-block} {if is_set( $loaded )} {include uri=concat('design:section', $node.object.section_id, '/column1.tpl')} {/if}
The first time the template is loaded variable $loaded is correctly set, subsequent times it does not.Is it a <i>feature</i>? (Or a bug?) ;-)
liu spider
Thursday 15 June 2006 8:03:20 pm
have a look here:http://ez.no/products/ez_publish/documentation/incoming/persistent_template_variable
http://liucougar.scim-im.org SCIM Input Method Platform http://scim.sf.net SJSD Online Editor http://sf.net/projects/sjsd
Friday 16 June 2006 1:03:04 am
Nice try! :-)Unfortunately $module_result is not available in overridden templates, so it is not useful for me at this time, since I need to know it in a override template.
:-(