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.