Forums / General / Custom Tag Caching Problems

Custom Tag Caching Problems

Author Message

John Smith

Friday 19 January 2007 10:15:27 am

Hi there,

Hope someone can help. I have created a custom tag but facing some problem with caching.

In a folder, I have created an article with the custom tag in it. The main function of the custom tag is to fetch latest five articles from some node id. But when I create a new article in the specific node from where the custom tag is getting the data is not fetching the new article.

Everytime to get the result I have to manually clear the cache.

Please help...

Smith

Paul Borgermans

Friday 19 January 2007 4:16:05 pm

Hi John,

This is "by design" with using the content view caches and a bit hard to avoid. However, can't you have the same functionality without the custom tag?

For example, another scenario is that the article has dedicated attribute replacing the custom tag, possibly with the parent node id from which you want to fetch the latest 5 new items. In that case, you could make the article template so that it first turns off caching but for the "main" part it uses a normal cache block and for the part with the latest 5 articles no cache block.If there is no nodeid in the new article attribute, you just do not do a fetch.

Hth

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

John Smith

Saturday 20 January 2007 1:59:07 am

Hi Paul,

Thanks for you kind help.

Will the same thing as explained by you applies to folder class as well. Need to fetch articles from two/three nodes there.

For eg.

Folder A
|-> Subfolder B (10 articles)
|-> Subfolder C (20 articles)
|-> Subfolder D (15 articles)

In folder A, I want to fetch 5 articles from each of the subfolders. This means when I click folder A from the menu, it should display three boxes having 5 articles from each of the subfolders.

Thats why I have created custom with node id as parameter to be passed while inserting the custom tag. In this way I can use that custom tag anywhere where I want to fetch latest five articles.

My problem is when I insert any new article in subfolder B, C, D, the listing on the page A does not get updated.

Is my problem a bug or I am looking for something impossible.

Please help.....

Cheers
Smith

kracker (the)

Saturday 20 January 2007 3:26:16 am

Well, you did do a great job giving further information about what your exactly trying to do.

The main problem is ... you need to stop using that custom tag, it is <b>not</b> going to meet your needs.

After you let go that the custom tag is not the 'best' solution, <i>then</i> we can move forward.

I would recommend creating a custom template which would contain the fetch and display your lists of content. You may also read up on the use of cache blocks, <i>http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/miscellaneous/cache_block</i>

<i>hth,
//kracker

tv : squidbillies</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

John Smith

Saturday 20 January 2007 7:09:47 am

Hi,

Would it be possible for you to guide me bit more in details.

Cheers
Smith

kracker (the)

Saturday 20 January 2007 7:23:57 am

Ask a specific question ...

Read up, try to create a toolbar item as an example exercise ...

<i>http://ez.no/ezpublish/documentation/customization/components/toolbars/adding_new_tools_to_toolbar_list
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/visualization/tool_bar
http://ez.no/content/advancedsearch?SearchText=toolbar&SearchContentClassID=9&SearchPageLimit=5</i>

If you can write a custom tag you should (with some work) be able to integrate your code into a template to include in your pagelayout.tpl whether with a simple 'include' of another template with the code or using a toolbar.

//kracker

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Paul Borgermans

Saturday 20 January 2007 9:08:31 am

Here you go :-)

In the template for your article, put the following at the top:

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

Surround your article content with

{cache-block}
{*your article content*}
{/cache-block}

and use the following where you fetch the latest articles:

{cache-block subtree_expiry='mynews/folderx''}
{*fetch ....*}
{/cache-block}

hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans