This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Setup & design » Include and cache
expandshrink

Include and cache

Include and cache

Wednesday 02 November 2011 3:42:01 pm - 9 replies

Hi ez community,

I try to configure a template for specific users. 

I overrode the template article in full view. In this template, i included another template which is specific for a group of users.

So my code looks like this

<h1>{$node.data_map.title.content|wash()}</h1>
...
{attribute_view_gui attribute=$node.data_map.body}
 
{include uri='design:maps.tpl'} 

To enable dynamic content I added on the top of the template "maps.tpl":

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

With some tests, i concluded that nothing is cached. The dynamic content is only present in the maps.tpl file. Is it possible to store some parts of the first template in a cache file?

Thanks in advance.

Wednesday 02 November 2011 3:53:30 pm

Hello Sylvain,

Yes, I recommend considering using cache blocks.

http://doc.ez.no/eZ-Publish/Techn...aneous/cache-block/(language)/eng-GB

 

Cheers,

Heath

Wednesday 02 November 2011 3:59:18 pm

Hello Sylvain,

Yes, I recommend considering using cache blocks.

http://doc.ez.no/eZ-Publish/Techn...aneous/cache-block/(language)/eng-GB

 

Cheers,

Heath

Hi Heath,

I tested cache-block without success. Is the cache-block operator only available in pagelayout.tpl?

Wednesday 02 November 2011 4:15:57 pm

Hello Sylvain,

No, cache blocks are available to any and all templates.

What are you trying to actually accomplish here?

 

Cheers,

Heath

Modified on Wednesday 02 November 2011 5:31:36 pm by // Heath

Wednesday 02 November 2011 4:17:40 pm

Ahh,

Another note, if your cache disable code is only in the maps.tpl

Then your full view template should (since it is a separate template file)

already be cached normally and using cache blocks in it may be over kill, I'm not so certain ..

 

Cheers,

Heath

Modified on Wednesday 02 November 2011 4:17:53 pm by // Heath

Thursday 03 November 2011 5:53:39 pm

We had a similar problem and we solved it this way:

{def $user=fetch( 'user', 'current_user' )}
{def $cachekey = $user.groups}
{cache-block expiry=0 keys=$cachekey}
....
{/cache-block}

Friday 04 November 2011 8:55:26 am

Thanks Peter,

It's very similar to what I tested except expiry parameter.

I will try this.

Friday 04 November 2011 9:31:19 pm

The full view templates should not be cached by the pagelayout.tpl cache blocks but by the View Cache. So you need:

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

at the top of the full view tpl file then use {cache} block inside

fullview.tpl

{set-block scope=root variable=cache_ttl}0{/set-block}
 
blablabla...
 
{cache-block expiry=XXXX keys=ID_FOR_SPECIFIC_USER}
 
blabla...
 
{/cache-block}
 
blablabla...
 
{cache-block expiry=XXXX keys=ID_FOR_SPECIFIC_GROUP}
 
{include uri='design:maps.tpl'}
 
{/cache-block}

Modified on Friday 04 November 2011 9:33:06 pm by Quoc-Huy NGUYEN DINH

Friday 04 November 2011 9:47:53 pm

Hi Huy,
thanks for your contribution to my question.

I know that the full view is cached with the view cache.
This afternoon, I tried exactly what you explained without success... Result: a headhache !

I will not give up...

Friday 04 November 2011 10:37:03 pm

Just to make sure you could add a

{currentdate()|datetime( 'custom', '%h:%i %a %d %F %Y' )}

inside each cache blocks.

Clear the cache, load the page you will see a date. Wait a bit and reload and see if the date/time stays or changes.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from