Problem with cache-block function in a template override

Problem with cache-block function in a template override

Sunday 23 March 2008 9:17:28 am - 4 replies

Author Message

André R.

Sunday 23 March 2008 10:24:15 am

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

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Daniele Nocentini

Tuesday 25 March 2008 7:28:26 am

Thanks andrè for tips, now works.
But I have another cache understanding problem, I have also a list of file excel file download from fecth in a folder on content structure, I want to show the number of download but with template compile on and content cache on this count does not update.

this is my code for the link download inside a foreach:

{cache-block expiry=20 keys=$child.data_map.file.content.main_node.data_map.file.content.original_filename|urlencode}
		<a href={concat( 'content/download/', $child.data_map.file.content.main_node.data_map.file.contentobject_id, '/', $child.data_map.file.content.main_node.data_map.file.id,'/version/', $child.data_map.file.content.main_node.data_map.file.version , '/file/', $child.data_map.file.content.main_node.data_map.file.content.original_filename|urlencode )|ezurl}><img src={"download.png"|ezimage} border="0" alt="{$child.data_map.file.content.main_node.data_map.file.content.download_count} download" title="{$child.data_map.file.content.main_node.data_map.file.content.download_count} download" /></a>
		&nbsp;{$child.data_map.file.content.main_node.data_map.file.content.download_count}
		{/cache-block}

Antica Bottega Digitale srl
http://www.abd.it

André R.

Wednesday 26 March 2008 11:20:56 am

First of all, you should remove that cache block (cache blocks introduce overhead as well, so you should not use them inside a foreach like that), you problem is probably that this code is inside another cache block or view cache.

Introduction to cache blocks:

{cache-block expiry=3600 ignore_content_expiry}
    {cache-block expiry=20}
    This code will update every hour {currentdate()|l10n( 'shortdatetime' )}
    {/cache-block}
{/cache-block}

Same goes for content view cache ( inside a view/full node template ):

{set-block scope=global variable=cache_ttl}3600{/set-block}
    {cache-block expiry=20}
    This code will update every hour {currentdate()|l10n( 'shortdatetime' )}, unless this node is edited!
    {/cache-block}

The text will only update if the node is edited if cache_ttl is not explicit set, and text will update every 20 seconds if cache_ttl is set to 0 (disable view cache).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Daniele Nocentini

Monday 12 May 2008 2:09:44 am

If possible to not cached a part of template like this:

{non-cache-block}

bla bla bla

{/non-cache-block}

Antica Bottega Digitale srl
http://www.abd.it

You must be logged in to post messages in this topic!

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