Kristoffer Karlsson
|
Tuesday 03 July 2007 7:59:45 am
Please... I have been fighting with this problem for a long time. I show a random article from node 252 on my frontpage. I have to clear the cache, or publish new content, to get a new article to be shown. Viewcaching in enabled. The code from the template below. Can anyone give me a hint?
<div class="box-embgv">
<div class="tl"><div class="tr"><div class="br"><div class="bl"><div class="box-content">
{def $children = array()
$limit = 1
$offset = 0}
{if is_set( $object_parameters.limit )}
{set $limit = $object_parameters.limit}
{/if}
{if is_set( $object_parameters.offset )}
{set $offset = $object_parameters.offset}
{/if}
{set-block scope=root variable=cache_ttl}0{/set-block}
{cache-block expiry=0}
{def $max=fetch('content', 'tree_count', hash(parent_node_id, 252))}
{set $children=fetch( content, list, hash( 'parent_node_id', $object.main_node_id, 'limit', $limit, 'offset', rand(0,$max|sub(1)), 'sort_by', $object.main_node.sort_array ) ) }
<div class="content-view-children float-break">
{if $children|count()}
{foreach $children as $child}
{node_view_gui view=line content_node=$child}
{/cache-block}
{/foreach}
{/if}
</div>
_____________________________________
Blog: http://www.kristofferkarlsson.com
Website: http://www.spelkanalen.com
|
Marco Zinn
|
Tuesday 03 July 2007 9:39:36 am
Hi, please check these things:
1. Your foreach loop overlaps the cache-block boundaries. Please move the end of the foreach to withing the cache-block
2. {set-block scope=root variable=cache_ttl}0{/set-block} will set the Time To Live of the Content Cache for this node to 0, disabeling the cache. This should be the right way to do this. I had to use "scope=global" once to get it working, but i think, i had used an include file then. 3. {cache-block expiry=0} Means, that you define a cache-block around your output, which will last forever (99% sure, please check the docs on "cache-block"). You should remove this cache-block or set the expiry time to something usefull. Default is "2 hours", i think, maybe try expiry=30 , which means 30 seconds. For testing, i'd recommend to remove the cache-block statements. EDIT: :) I was on the phone, while i wrote this comment. I didn't want to duplicate André's entry, they just "overlapped in time" ;)
Marco
http://www.hyperroad-design.com
|
Kristoffer Karlsson
|
Thursday 05 July 2007 7:23:29 am
Thanks for your trying to help me. I have moved the {set-block scope=root variable=cache_ttl}0{/set-block} to the top of the template and removed the cache-blocks. It now works if I disable view-caching. If I turn it on I get the same article every time. The code I posted is from the template horizontally_listed_subitems. I also added {set-block scope=root variable=cache_ttl}0{/set-block} to the pagelayout.tpl and the article-line.tpl, but with no result. I am a beginner to ez and I am really greatful for your help.
_____________________________________
Blog: http://www.kristofferkarlsson.com
Website: http://www.spelkanalen.com
|