Re: [SMARTY-DEV] First step tosolve {nocache} {/nocache}problematic

From: Date: Mon, 27 Jan 2003 14:41:18 +0000
Subject: Re: [SMARTY-DEV] First step tosolve {nocache} {/nocache}problematic
References: 1 2 3 4 5 6 7 8 9  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-631@lists.php.net to get a copy of this message
On Mon, 2003-01-27 at 04:21, André Rabold wrote: > Regarding the use of a "nocache=true" parameter: > Here's a simple example: The {section} tag. Should a section be cached or > not? > > {* $bar is set to cache *} > {$bar|@count} entries: > {section name="foo" loop=$bar nocache=true} > {$bar[foo]} > {/section} > --> POSSIBLY UNEXPECTED RESULTS > > {* $bar is set to no-cache *} > {$bar|@count} entries: > {section name="foo" loop=$bar} > {$bar[foo]} > {/section} > --> POSSIBLY UNEXPECTED RESULTS > > {* $bar is set to no-cache *} > {$bar|@count} entries: > {section name="foo" loop=$bar nocache=true} > {$bar[foo]} > {/section} > --> RIGHT RESULTS > > It is really complicated to use no-cached variables for the template > designer because he whould have to know whether a variable is cached or not. > > So I think a function should not be cached if it is using a non-cached > variable. Otherwise it will get complicated for the designer. If the > programmer desides to change the caching behaviour of a variable he would > have to call the designer to change the templates ?!?!! Yes cached variables may not even be feasible. Caching might be function driven only, or possibly template driven too. > > > Some more things to think about: if a variable is passed to an included > > template, does it inherit the caching behavior? Same with vars that get > > assigned to another var name. > > > Including templates combined with caching gets cruel. That's the reason why > I would change the behaviour of the {include} tag a bit: > Included templates use the same variable scope as the parent one, don't > they? That is not a really good programming technique I think. A included > template could easily destroy the parent's variables. Includes should work > like a subfunction call. So you have to manually set the parameters the > included template should be able to use. If you want to use the same scope > you have to set a special parameter. > And in this case the include get's (never?) cached. Otherwise the caching > depends on the given parameters like if using a normal function. Included templates inherit the parent vars, but they are within their own scope, much like a function. Monte

« previous php.smarty.dev (#631) next »