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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 05:22:03
Script start
Timing: Jan 18 2025 05:22:03
Module start 'layout'
Timing: Jan 18 2025 05:22:03
Module start 'content'
Timing: Jan 18 2025 05:22:03
Module end 'content'
Timing: Jan 18 2025 05:22:03
Script end

Main resources:

Total runtime0.0226 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0085 589.1797152.6406
Module start 'layout' 0.00860.0044 741.820339.4922
Module start 'content' 0.01290.0073 781.312593.3672
Module end 'content' 0.02020.0024 874.679734.3047
Script end 0.0226  908.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003415.2184140.0002
Check MTime0.00167.0117140.0001
Mysql Total
Database connection0.00104.499710.0010
Mysqli_queries0.004519.756030.0015
Looping result0.00010.538010.0001
Template Total0.00198.210.0019
Template load0.00104.306010.0010
Template processing0.00093.819610.0009
Override
Cache load0.00062.799410.0006
General
dbfile0.00052.272080.0001
String conversion0.00000.061140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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