Forums / Developer / Template Reload after Module $tpl-> variable updates

Template Reload after Module $tpl-> variable updates

Author Message

Håkan Bergman

Monday 31 May 2010 7:53:54 am

Hello,

I tried to find similar posts but couldn't find any information about it.

I am using a module with /extension-name/search which loads the search template with the $tpl->setVariable( 'show_result', 0). This is working fine. In the TPL file I have a form that submits to same module which makes a DB Query and returns the result. The result is working fine and I can echo different results from the script that verifies when a result was made and when nothing was found.

But the $tpl->setVariable( 'show_result', 1) doesnt work (I thought). Now I think it works and the template is just being cached and ignores the template update value. How can I force the template to update on every query?

My test was simple with this code:

if ($_POST) {

echo "Returned post";

$tpl->setVariable( 'show_result', 1);

} else {

echo "no post was made";

$tpl->setVariable( 'show_result', 0);

}

When I write {$show_result} in template it shows 0. But after $_POST I can see "Returned post" but it still prints 0. Is is possible to disable cache for only this page and cache all others? Is it a cache problem or a code issue? I don't know where to look, if to cache or to my code.

Best regards,

Håkan Bergman

Håkan Bergman

Monday 31 May 2010 7:59:12 am

I did a second test.

I did a $_POST and then cleared cache, updated browser which alread had a post, accepted it and the text turned.

It seem that this is a 100% cache problem.

Håkan Bergman

Monday 31 May 2010 8:16:36 am

I tried to disable cache in my search.tpl file, but I didn't get it to work.

Then I inserted this into override settings in site.ini.appen.php:

[ContentSettings]
ViewCaching=disabled

[TemplateSettings
]TemplateCache=disabled

[OverrideSettings]
Cache=disabled

This worked, but probably not the best solution.

André R.

Tuesday 01 June 2010 4:41:25 am

Do you have a cache-block that is to aggresive inside your template maybe? check by only disabling TemplateCache.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom