Template caching - Pagelaout & View

Author Message

Simon Phillips

Tuesday 15 February 2005 4:38:10 am

Hi,

I'm trying to add node translation information to a menubar - specifically, I want to include the following language link code in a menubar that's specified in pagelayout.tpl:

{* Code to show list of translations *}
{* to use pictures, instead of text uses st.like this: 'esl-ES',concat('<img src=',"picture_name.png"|ezimage,'/>') *}

{let languages=hash('cat-ES','Catalan', 'chi-CN','Chinese', 'cze-CZ','Czech', 'dan-DK','Danish', 'dut-NL','Dutch', 'eng-CA','English (Canada)', 'eng-GB','English (United Kingdom)', 'eng-US','English', 'esl-ES','Español', 'esl-MX','Castillan', 'fin-FI','Finnish', 'fre-CA','French (Canada)', 'fre-FR','Français', 'ger-DE','German (Germany)', 'hun-HU','Hungarian', 'ita-IT','Italian', 'nno-NO','Norwegian (Nynorsk)', 'nor-NO','Norwegian (Bokmal)', 'pol-PL','Polish', 'por-BR','Portuguese (Brasil)', 'por-MZ','Portuguese (Mozambique)', 'por-PT','Portuguese (Portugal)', 'rus-RU','Russian', 'swe-SE','Swedish')

all_translations=$node.object.current.translation_list}
    {section show=$all_translations|count|gt(0)}
	    {section var=translation loop=$node.object.current.translation_list}
                <a href={concat($node.url_alias,'/(language)/',$translation.item.language_code)|ezurl}>{$languages[$translation.item.language_code]}</a> | 
            {/section}
    {/section}
{/let}

However, this only displays on the first view of the page after a cache clear; Subsequent views (loaded from the template cache) don't work because this references $node and not $module_result - which is not available at the pagelayout level (http://www.ez.no/ez_publish/documentation/customization/custom_design/template_variables_set_by_ezpublish)

Unfortunately, $module_result doesn't hold any translation data, so I can't select on that instead. How else can I display this translation info? The obvious alternative is to put it in a view-level template; but this means that I'll need to put a fair amount of site structure at the view level - ie menu bars, etc - and since I already customise my view/content/full.tpl files for different content types, I don't want to have to edit each of these each time I want to change a bit of structure.

How does everyone else handle this sort of thing?

Can I force a template block to be <b>not cached</b>?

Thanks,
Simon

Arran Price

Wednesday 16 February 2005 1:34:36 pm

Hi Simon,
I dont quite understand the question but the template block not caching rings a bell.
Take a look at:
http://ez.no/community/forum/setup_design/ezhttp_get_problem/#msg79334
Is this what you are after?

{set-block scope=root variable=cache_ttl}0{/set-block}

Not sure if thats what you want, but just in case it is...

Arran

Simon Phillips

Wednesday 16 February 2005 2:14:52 pm

Thanks Arran,

I've been working on this problem for a day now, and yep - that's one possible solution. However, then the entire pagelayout template isn't cached, which is far from idea.

The solution I settled on is to use the fetch function to retrieve the node, and work with the retrieved node instead. This data is not cached, and so will update as the page contents change.

Simon

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 22:24:26
Script start
Timing: Jan 18 2025 22:24:26
Module start 'layout'
Timing: Jan 18 2025 22:24:26
Module start 'content'
Timing: Jan 18 2025 22:24:26
Module end 'content'
Timing: Jan 18 2025 22:24:26
Script end

Main resources:

Total runtime0.8878 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.0046 589.3438152.6250
Module start 'layout' 0.00460.0023 741.968839.4609
Module start 'content' 0.00690.8795 781.4297479.8672
Module end 'content' 0.88640.0014 1,261.296912.1563
Script end 0.8878  1,273.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00280.3150160.0002
Check MTime0.00120.1311160.0001
Mysql Total
Database connection0.00050.055210.0005
Mysqli_queries0.842694.9142570.0148
Looping result0.00060.0672550.0000
Template Total0.859596.820.4298
Template load0.00180.198220.0009
Template processing0.857896.615920.4289
Template load and register function0.00020.020310.0002
states
state_id_array0.00100.112610.0010
state_identifier_array0.00110.128720.0006
Override
Cache load0.00140.1582260.0001
Sytem overhead
Fetch class attribute can translate value0.00090.102420.0005
Fetch class attribute name0.00170.194630.0006
XML
Image XML parsing0.00020.025020.0001
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00110.1282100.0001
String conversion0.00000.000840.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
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
2content/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: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs