Problems with cache-blocks and layout/set link generation?

Author Message

Massimiliano Bariola

Thursday 20 July 2006 10:13:28 am

Hi,

I am encountering some problems which I cannot diagnose: see the following piece of code.

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

{cache-block keys=$node.node_id subtree_expiry='content/view/full/60' expiry=86400}
								<ul>
								{set $links = fetch(content, list, hash(parent_node_id, 60,
																		sort_by, array('priority', true())))}
								{foreach $links as $link}
								{if $link.node_id|eq($node.node_id)}
									<p class="orange_no_link"><img src={'arrows_no_linksx.gif'|ezimage} border="0">{if $link.object.data_map.nome_abbreviato.data_text|count|gt(0)}{attribute_view_gui attribute = $link.object.data_map.nome_abbreviato}{else}{attribute_view_gui attribute = $link.object.data_map.nome}{/if}</p>
								{else}
									<li><a href={$link.url_alias|ezurl}>{if $link.object.data_map.nome_abbreviato.data_text|count|gt(0)}{attribute_view_gui attribute = $link.object.data_map.nome_abbreviato}{else}{attribute_view_gui attribute = $link.object.data_map.nome}{/if}</a></li>
								{/if}
								{/foreach}
								</ul>							
........


{/cache-block}

It displays the names of some fetched nodes or some short name, depending on whether the short name is set or not, and makes the link clickable or not based on which node I am viewing.

I am encountering this problem: when caches are generated after a manual deletion via admin interface, everything works well. but it happens that sometimes, the links generated by this code contain a layout/set/print part which makes the template be displayed as if it were a print layout. this template has no provisions for generating print layout links, so I am wondering what causes this problem.

Has anyone had this problem?
Cheers,

Max

Kristian Hole

Wednesday 26 July 2006 9:09:39 am

Hi Massimiliano,

I have not seen this, but i can imagine one reason for this: Do you use the print-layout on the site?

If the cache is regenerated at the exact moment when somebody views the print layout, that will be stored and used for later, since that is not part of the keys to the cacheblock.

I think you can also use $link.object.data_map.nome_abbreviato.has_content instead of the counting?

Cheers
-Kristian

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Kristof Coomans

Wednesday 26 July 2006 9:48:35 am

Hello Kristian

Is there a way to add $eZSys->AccessPath (see eZSys::addAccessPath used by the layout/set view) to the cache block keys?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Kristian Hole

Wednesday 26 July 2006 10:14:41 am

Hi Kristof,

I actually do not know.

But one option would be to use $link.url|ezurl as a cache key, since that includes the layout/set if that is active. Maybe cheating a little, but it should work...

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Kristian Hole

Wednesday 26 July 2006 10:26:02 am

In the pagelayout you can ofcourse use $module_result.requested_uri_string (if i remember the correct name of the variable) as a cache key, but that does not work inside the node-view-template which is what he is using here.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Massimiliano Bariola

Thursday 27 July 2006 1:19:48 am

Hi Kristian and Kristof,

indeed we do use print layouts on some other templates, but those templates refer to node-view tempates, while the template shown here is for a dummy node (used to display info about other nodes spread over the content tree). So I think that at least the $node.node_id value should be different thus differentiating the cache block keys.

Anyway, I will try that $link.url|ezurl trick and see if it solves the problem (if it's usable from a node-view tpl)

Thanks for now, I'll keep you posted

Massimiliano

Massimiliano Bariola

Thursday 27 July 2006 2:34:04 am

I tried the $link but it seems it is not defined in nodeview templates. I don't seem to be able to access that info anywhere else in the $node variable. any help?

Kristian Hole

Thursday 27 July 2006 8:24:46 am

Sorry, my bad.

I ment to use "$node.url|ezurl(no)" as a key.

The (no) is just to remove the quotes which ezurl adds.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

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 21 2025 04:22:04
Script start
Timing: Jan 21 2025 04:22:04
Module start 'layout'
Timing: Jan 21 2025 04:22:04
Module start 'content'
Timing: Jan 21 2025 04:22:05
Module end 'content'
Timing: Jan 21 2025 04:22:05
Script end

Main resources:

Total runtime1.3258 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.1719151.2422
Module start 'layout' 0.00630.0024 739.414136.7109
Module start 'content' 0.00871.3161 776.1250671.5703
Module end 'content' 1.32480.0009 1,447.695323.7813
Script end 1.3257  1,471.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2509160.0002
Check MTime0.00140.1068160.0001
Mysql Total
Database connection0.00130.097410.0013
Mysqli_queries1.257094.8142740.0170
Looping result0.00080.0621720.0000
Template Total1.292897.520.6464
Template load0.00190.139820.0009
Template processing1.290997.373720.6455
Template load and register function0.00010.010310.0001
states
state_id_array0.00080.062510.0008
state_identifier_array0.00110.084320.0006
Override
Cache load0.00160.1197470.0000
Sytem overhead
Fetch class attribute can translate value0.00070.050130.0002
Fetch class attribute name0.00110.0798110.0001
XML
Image XML parsing0.00330.250530.0011
class_abstraction
Instantiating content class attribute0.00000.0024160.0000
General
dbfile0.00280.2085290.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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/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/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: 32
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs