eZ Community » Forums » Setup & design » Redifine cache-block in cache-block

Redifine cache-block in cache-block

Redifine cache-block in cache-block

Monday 04 March 2013 12:07:25 pm - 1 reply

I have a cache block with expiry parameters. but expiry parameters are base on nodes i don't want to fech if the cache-block existe.... 

Does it work?

{** * tpl included in pagelayout.tpl *}

{cache-block keys='maintenance'}{* First 'maintenance' cache-block define. used if it is already defined *}
{def $maintenance = fetch_by_remote_id( 'maintenance' ) } 
{def $currentDate = currentdate() }
{def $messages_params= hash(  'parent_node_id', $maintenance.node_id, 'attribute_filter', array( array( 'maintenance_message/fin_publication', '>=', $currentDate ) ), 'limit', 1 ) }
{def $messages=fetch(content, list, $messages_params)}

{foreach $messages as $message}
{cache-block keys= 'maintenance'
  {* Second 'maintenance' cache-block define. Used for defined expiry parameters *}
  <div class="CLASS_maintenance_message"> <!-- My message --> </div>
{/cache-block} {* end of second cache-block *}

{/cache-block} {* end of first cache-block *}

Modified on Monday 04 March 2013 12:12:50 pm by Rémy PHP

Monday 04 March 2013 8:17:59 pm

Won't work. Cache blocks are dumb, they store the result as plain text and reuse that until its own block is 1. executed (so meaning parent view/block cache needs to be expired in tandem) and 2. verified to be expired.

So always have the most expiring blocks in the outer parts, and the long-lasting once can be one the inside.

Modified on Monday 04 March 2013 8:18:20 pm by André R


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from