Variable visibility through templates

Author Message

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

Stefano Guandalini

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?) ;-)

g

Stefano Guandalini
http://www.nizan.net

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

Stefano Guandalini

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.

:-(

g

Stefano Guandalini
http://www.nizan.net

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 15:01:41
Script start
Timing: Jan 18 2025 15:01:41
Module start 'layout'
Timing: Jan 18 2025 15:01:41
Module start 'content'
Timing: Jan 18 2025 15:01:42
Module end 'content'
Timing: Jan 18 2025 15:01:42
Script end

Main resources:

Total runtime1.0640 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 588.0313152.6406
Module start 'layout' 0.00700.0031 740.671939.4766
Module start 'content' 0.01011.0523 780.1484557.0156
Module end 'content' 1.06240.0015 1,337.164112.1406
Script end 1.0639  1,349.3047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3633160.0002
Check MTime0.00140.1303160.0001
Mysql Total
Database connection0.00070.069910.0007
Mysqli_queries1.003994.3590600.0167
Looping result0.00070.0672580.0000
Template Total1.027996.620.5140
Template load0.00200.188420.0010
Template processing1.025996.422120.5129
Template load and register function0.00010.007210.0001
states
state_id_array0.00120.115810.0012
state_identifier_array0.00230.215620.0011
Override
Cache load0.00160.1535300.0001
Sytem overhead
Fetch class attribute can translate value0.00110.105020.0006
Fetch class attribute name0.00140.134360.0002
XML
Image XML parsing0.00150.141220.0008
class_abstraction
Instantiating content class attribute0.00000.002380.0000
General
dbfile0.00110.1064220.0001
String conversion0.00000.000740.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs