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

eZ debug

Timing: Jan 29 2025 23:47:39
Script start
Timing: Jan 29 2025 23:47:39
Module start 'content'
Timing: Jan 29 2025 23:47:39
Module end 'content'
Timing: Jan 29 2025 23:47:39
Script end

Main resources:

Total runtime0.0126 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.0781180.8125
Module start 'content' 0.00590.0034 768.890697.9297
Module end 'content' 0.00930.0032 866.820374.7031
Script end 0.0126  941.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002016.1315120.0002
Check MTime0.00107.8501120.0001
Mysql Total
Database connection0.00075.686710.0007
Mysqli_queries0.002620.634340.0007
Looping result0.00000.151320.0000
Template Total0.003023.810.0030
Template load0.00075.726410.0007
Template processing0.002318.062310.0023
Override
Cache load0.00053.808810.0005
General
dbfile0.00032.2334100.0000
String conversion0.00000.032130.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs