Forums / Setup & design / Cache and random

Cache and random

Author Message

Andreas Kaiser

Wednesday 23 July 2008 1:09:28 pm

Hi,

I'm using following code inside a template called from the pagelayout.tpl in ezp 4:

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

<div id="banner">
{def $nrbanners=fetch( 'content', 'tree_count', hash( 'parent_node_id', 358, 'class_filter_type', 'include', 'class_filter_array', array('banner') ) )}
{def $randombanner=fetch( 'content', 'tree', hash( 'parent_node_id', 358, 'class_filter_type', 'include', 'class_filter_array', array('banner'), 'offset', rand(0, dec($nrbanners)), 'limit', 1 ) )}
{content_view_gui content_object=$randombanner[0] view=random}
{undef $nrbanners $randombanner}
</div>

This code is working in other sites (same install), but in this case random isn't working. first time loaded object is show every refresh.

Any ideas?

Anyway with TemplateCache=disabled in site.ini random works.

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/

André R.

Wednesday 23 July 2008 1:24:54 pm

cache_ttl is for setting view cache timeout(the one used on node templates), no effect on cache-blocks what so ever.

How much is performance a concern on this site?

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

Andreas Kaiser

Wednesday 10 September 2008 11:22:36 am

It's not a high load site, so performance is not a problem...

Is there any alternative for displaying random content with cache enabled? I've tried "shuffle" extension and same problem...

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/