Re:[BEGINNER] Question about caching

From: Date: Mon, 31 Dec 2001 23:49:20 +0000
Subject: Re:[BEGINNER] Question about caching
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2458@lists.php.net to get a copy of this message
Thanks Andrei. I thought I tried that, and I did catch that bug on some of the other pages, but I'll try it again. Because that seems to make sense. I'll post a message back when I have time to try it out. Again, I really appreciate all the help everyone has given throughout these problems! Thanks! Brian ------------------------------------ "How should I know if it works? That's what beta testers are for. I only coded it." - Linus Torvalds ----- Original Message ----- From: Andrei Zmievski <andrei@ispi.net> To: smarty@lists.ispi.net Date: 12/31/01 6:07:16 AM > >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. * > >--- >You are currently subscribed to smarty as: brian@massassi.net >To unsubscribe send a blank email to $subst('Email.Unsub') >Visit Smarty's homepage at >http://www.phpinsider.com/php/code/Smarty/

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