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

From: Date: Fri, 28 Dec 2001 23:05:49 +0000
Subject: Re:Re:Re:Re:[BEGINNER] Question about caching
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2429@lists.php.net to get a copy of this message
>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. ----- Original Message ----- From: Andrei Zmievski <andrei@ispi.net> To: smarty@lists.ispi.net Date: 12/28/01 2:58:25 PM > >On Fri, 28 Dec 2001, Brian E. Lozier wrote: >> >I see. Your best bet then would be to use the fetched contents of inner >> >template as the $cache id. Alternatively, you can use $RESOURCE URI or >> >some other cache id on fetch() call and don't use it on display() since >> >the main template is so simple. >> >> But that's the problem! If I use it on the inner fetch() calls, then do a standard >> $tpl- >display('main.tpl') >> it returns the same cached file NO MATTER WHAT PAGE I'M ON. Whatever page is called >> *FIRST* after turning on >> caching, that's the one that gets cached, no matter what I pass in $tpl->fetch() as >> the cache_id. It just >> ignores that. >> >> How do cache IDs work? Is there a specific cache_id for each template? Like, if I have: >> >> main.tpl => cache_id: 5 >> main.tpl => cache_id: 6 >> main.tpl => cache_id: 7 >> >> Then can I have also: >> >> index.tpl => cache_id: 5 >> index.tpl => cache_id: 6 >> index.tpl => cache_id: 7 >> >> And those are all completely separate cache files? Or is the cache_id unique per the >> directory, meaning, you >> will never get repeats no matter what template you're compiling? > >Yes, cache_id does not depend on the template. You can have cache_id of >5 for main.tpl and cache_id of 5 for index.tpl. > >> The only way I've even got it remotely to work correctly is if I pass $REQUEST_URI to >> *both* the ->fetch and >> the display, although they're both on completely separate templates (main.tpl and >> index.tpl). But then, >> looking at the cache, it actually caches it TWICE, once with the main.tpl wrapped around >> it, and one without. >> But that still doesn't solve the problem and I think it's actually making things >> slower because it has to >> write/test/read 2 separate cache files instead of just one. >> >> Using the fetched contents of the inner template.. how does cache_id work? Because >> that's a *lot* of data at >> times! >> >> I don't know whether you guys are dodging my questions or I'm just not being >> clear. Is there a way to insert >> cached data to a non-cached template? For instance: >> >> $tpl = new Smarty; >> 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'); >> >> In the above example, I *only* want the content of 'index.tpl' cached, nothing >> else. Is this possible? > >Well, set $tpl->caching = false right before you do display() and it >should work. > >-Andrei >* I don't mind going nowhere as long as it's an interesting path. * > >--- >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 (#2429) next »