Forums / Setup & design / Template caching - Pagelaout & View

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