Section missing through caching

Author Message

Jon Staines

Friday 08 December 2006 1:33:20 am

Hi everyone,

I've gone through every post related to caching and I still can't solve a problem I'm having in 3.6.10. I'm trying to show a block of text and an image as a copyright on certain pages. Whether to show it or not is decided by a check box in the classes which can have the copyright. It is only allowed to be shown in certain sections of the site (microsites under the main site). These sections have their own pagelayout template as an override. At the foot of this I had something like this:

{section show=$node.data_map.show_copyright.content}
Divs, images, text goes here
{/section}

This showed the image when the box was checked. But if you went to the page a second time, it disappeared. The node wasn't know the second time around. After a lot of forum searching and trial and error (the ttl 0 line at the top didn't fix it), I found that this stopped that problem:

{cache-block keys=array('copyright', $uri_string, $current_user.is_logged_in)}
{section show=$node.data_map.show_copyright.content}
Divs, images, text goes here
{/section}
{/cache-block}

Even though this had nothing to do with users being logged in it worked, both when users were logged in and not. I thought I had finally fixed it. But the next morning, the copyright was gone. More testing showed that it disappeared after the 2 hour cache default.

Can anyone help point out what I need to do/where I've gone wrong?

Regards
Jon Staines

André R.

Friday 08 December 2006 4:59:07 am

I kind of guess this is in the pagelayout or related templates -> You are not supposed to use $node in other templates then node templates. This is because the variable is only there (in pagelayout and included templates) when view caching is disabled or if the page you are viewing is not cached yet (no view cache for that node generated yet).

Edit: This is a long standing misunderstanding introduced at the time view cache was introduced to 3.x, this is fixed in 3.9 by removing the $node variable from pagelayout completely.

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

Jon Staines

Friday 08 December 2006 5:21:17 am

Thanks for the answer.

Would it be better to have something like this in the pagelayout:

{let $current_node=fetch(content,node,hash(node_id,$module_result.node_id))}
{section show=$current_node.data_map.show_copyright.content}

or

add some kind of section look up to some code in each of the node templates (article, folder, etc)?

Jon Staines

Tuesday 12 December 2006 1:22:51 am

The first option seems to have fixed the problem.

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

Main resources:

Total runtime0.8800 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.0055 589.0313152.6250
Module start 'layout' 0.00560.0032 741.656339.4609
Module start 'content' 0.00870.8696 781.1172560.5469
Module end 'content' 0.87840.0015 1,341.664112.1641
Script end 0.8799  1,353.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3654160.0002
Check MTime0.00130.1477160.0001
Mysql Total
Database connection0.00090.099510.0009
Mysqli_queries0.820593.2462600.0137
Looping result0.00080.0922580.0000
Template Total0.842795.820.4213
Template load0.00230.264820.0012
Template processing0.840395.497020.4202
Template load and register function0.00010.013210.0001
states
state_id_array0.00160.186810.0016
state_identifier_array0.00160.183220.0008
Override
Cache load0.00200.2240270.0001
Sytem overhead
Fetch class attribute can translate value0.00080.092520.0004
Fetch class attribute name0.00130.152660.0002
XML
Image XML parsing0.00100.116920.0005
class_abstraction
Instantiating content class attribute0.00000.001980.0000
General
dbfile0.00100.1130230.0000
String conversion0.00000.000940.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
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs