Re:Re:Re:Re:[BEGINNER] Question about caching

From: Date: Mon, 31 Dec 2001 14:07:16 +0000
Subject: Re:Re:Re:Re:[BEGINNER] Question about caching
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2452@lists.php.net to get a copy of this message
On Mon, 31 Dec 2001, Andrei Zmievski wrote: > On Fri, 28 Dec 2001, Brian E. Lozier wrote: > > >Well, set $tpl->caching = false right before you do display() and it > > >should work. > > > > Yeah, but it doesn't. It puts absolutely no content in place of {$Content} (just > > blank). It's like, since I > > set caching to false, it discards all cached content that I have previously retrieved. > > Well, of course. Look what you are asking it to do: > > if(!$tpl->is_cached('index.tpl', $REQUEST_URI)) { > // do my db calls > $dbInfo = mysql_db_junk(); > > // assign it > $tpl->assign('dbInfo', $dbInfo); > > // fetch the right template to include it > $tpl->assign('Content', $tpl->fetch('index.tpl', $REQUEST_URI)); > } > $tpl->display('main.tpl'); > > If index.tpl is not cached, everything is fine - it will fetch the > its content, assign them to $Content variable and display main.tpl. If > it is cached, no fetching or assignment takes place, and since Smarty > does not cache the assigned variables, $Content is empty by the time you > get to displaying main.tpl. It's a simple logic error. Try it like this: > > if(!$tpl->is_cached('index.tpl', $REQUEST_URI)) { > // do my db calls > $dbInfo = mysql_db_junk(); > > // assign it > $tpl->assign('dbInfo', $dbInfo); > } > > // fetch the right template to include it > $tpl->assign('Content', $tpl->fetch('index.tpl', $REQUEST_URI)); > $tpl->display('main.tpl'); Well, also put $tpl->caching = false before the display() call. -Andrei * Proximity bug: when the program crashes in front of important visitors. *

« previous php.smarty.general (#2452) next »