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 » Developer » uncache elements
expandshrink

uncache elements

uncache elements

Tuesday 26 July 2011 12:14:46 pm - 4 replies

Hello,

I try to uncache elements in many template (line_oi, full_oi). At moment, i try only on line_oi.tpl. (It's a list of object "oi"blunk.gif Emoticon

Actually i have:

{cache-block keys=array($node.node_id,ezhttp('carnet','session'))}
     {if} {"link: add_to_notepad"}
     {else} {"link: remove_from_notepad"}
     {/if}
{cache-block}

That's work if ezpublish cache is clear, however if I add / remove several elements from my notepad (carnet), the links aren't displayed correctly, I think they are cached because i display before in pagelayout template "ezhttp('carnet','session')" and i have the right elements while in line_oi template, i have corrupted elements. If i clear ez publish cache, the links are display correctly.

I tried :

- to use set-block in full_rubrique, line_oi templates but no effect.

- to add properties to cache-block.

If you can help me, advise me or if you have any questions, I'm interested.

Thanks

Tuesday 26 July 2011 12:52:26 pm

The problem is, I guess, that you are using your line_oi.tpl inside another node view template.

The caching basics in eZ is: the "view cache", part of the "content cache" stores one html chunk per node, when the page is accessed. The view cache is expired only when the node is edited, its children are edited, or related objects are edited.

Otoh the pagelayout (and templates included from it) is executed on every access.

Cache blocks are generally used to compensate this, eg. not to calculate on every page view the navigation menus, since they do not change frequently.

If you want to have a node view template that displays differently based upon some session variable for the user, you should in the first place deactivate the view cache for that node using this code:

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

(with XXX seconds), and only then think about introducing cache blocks.

More info:

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Features/View-caching

Modified on Tuesday 26 July 2011 12:53:57 pm by Gaetano Giunta

Tuesday 26 July 2011 12:56:34 pm

Hi Olivier, and welcome to the eZ Community, 

I am not sure whether you purposely simplified the code, but the {if} condition is missing the actual condition. Secondly : what type of data is stored in the session variable called 'carnet' ? An array ? A string ? Integer ?

Let us know,
Cheers,

Tuesday 26 July 2011 4:58:20 pm

Hi,

Thank you, the problem is solved.

I had other cache-block on other template (line_search_form.tpl).

Full_rubrique called Line_Search_Form and it called line_oi.

-_-'

Sunday 24 November 2013 5:22:39 pm

Hi,

we are adding code based on session value in header (in a header select and in menu).

The user select the city in header and menu is based on the city.

we use pagelayout.tpl without cache-block and we call page_header.tpl where we read session variable and depending of session variable we show different menu. Top menu depend of session value.

The session is set and unset in php code.

We are using 2013.6 legacy.

Thanks for help. Fran

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from