CacheBlock problem

Author Message

Julien Plesniak

Monday 06 August 2007 6:53:44 am

Hello, i have a problem with the cache.

I have a template which contain this code:

{if not(ezhttp('modif'))}
   {def $modific = 0}
{else}
   {def $modific = 1}
{/if}

{cache-block keys=array($uri_string, $i, $modific)}
{if $i|eq(0)}
    Text A
{else}
    {if $modific|eq(0)}
       Text B
    {else}
       Text C
    {/if}
{/if}
{/cache-block}

When i go to mywebsite, i have $i = 0 so I see the "text A", but when i click on a button (wich switch $i = 1 in database) i didn't see the "text B" but always "text A".

When i disabled the cache, the site works perfectly , i see TextB.

i try to add a cache block (in the example) but it doesnt work.

Whats the problem?

Thanks for help

André R.

Monday 06 August 2007 9:10:16 am

Could you show how $i is defined ?

Btw there are some bugs in the code:
1. ezhttp produce error if the variable you are getting is unset.
2. I hope this is only example code, since that cache block is a wast of resources
(there is no point in caching two if's)

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

Xavier Dutoit

Monday 06 August 2007 9:14:20 am

Is it a template for a view (full...) ? in that case, you have to disable the cache for this template (set ttl = 0 ) otherwise the node is cached, and it doesn't take into account the cache-block in the template.

X+

http://www.sydesy.com

Julien Plesniak

Monday 06 August 2007 11:39:17 pm

Hello, i add before my cache block

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

and it work perfectly. Thanks :)

Ps: Yes André, it is an example, reduced to be read on the forum ;)

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

Main resources:

Total runtime1.2862 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 587.7969152.6094
Module start 'layout' 0.00570.0026 740.406339.4297
Module start 'content' 0.00831.2763 779.8359588.8828
Module end 'content' 1.28460.0015 1,368.718812.1875
Script end 1.2861  1,380.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2582160.0002
Check MTime0.00150.1144160.0001
Mysql Total
Database connection0.00080.062210.0008
Mysqli_queries1.231995.7848620.0199
Looping result0.00090.0676600.0000
Template Total1.253397.420.6266
Template load0.00250.190720.0012
Template processing1.250897.250020.6254
Template load and register function0.00010.009410.0001
states
state_id_array0.00120.092410.0012
state_identifier_array0.00180.140020.0009
Override
Cache load0.00210.1640270.0001
Sytem overhead
Fetch class attribute can translate value0.00040.033530.0001
Fetch class attribute name0.00210.159560.0003
XML
Image XML parsing0.00120.095230.0004
class_abstraction
Instantiating content class attribute0.00000.001660.0000
General
dbfile0.00140.1075230.0001
String conversion0.00000.000540.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/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
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/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: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs