Re: Question about selective caching.

From: Date: Fri, 11 Jan 2002 23:13:01 +0000
Subject: Re: Question about selective caching.
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2521@lists.php.net to get a copy of this message
This is an interesting approach to switch caching on and then off. I was always using two or more Smarty objects (instances) with one having caching enabled and the other not... this could make things a lot easier ;) ----------------------- Alain Fontaine Consultant & Developer VAlain S.A. Tel: +32-4-2522950 ----------------------- -----Original Message----- From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte Ohrt Sent: Friday, January 11, 2002 5:30 PM To: smarty@lists.ispi.net Cc: smarty@lists.ispi.net Subject: [smarty] Re: Question about selective caching. One way to do it: $smarty->caching = true; $tpl1 = $smarty->fetch("internal1.tpl"); $tpl2 = $smarty->fetch("internal2.tpl"); $tpl3 = $smarty->fetch("internal3.tpl"); $smarty->assign("tpl1_contents",$tpl1); $smarty->assign("tpl2_contents",$tpl2); $smarty->assign("tpl3_contents",$tpl3); $smarty->caching = false; $smarty->display('index.tpl'); index.tpl --------- <table> <tr> <td>{$tpl1_contents}</td> <td>{$tpl2_contents}</td> <td>{$tpl3_contents}</td> </tr> </table> Another approach: You could write a custom insert function to fetch your internal templates: <table> <tr> <td>{insert name=fetch_tpl tpl="internal1.tpl"}</td> <td>{insert name=fetch_tpl tpl="internal2.tpl"}</td> <td>{insert name=fetch_tpl tpl="internal3.tpl"}</td> </tr> </table> Luc Saint-Elie wrote: > > Hello all, > > Its still me with my infamous caching problems..... > > My web site is some kind of portal-like site with a main template (*.tpl) > named index.tpl that is some kind of table and that includes a lot of other > templates files (*.tpl) in each of the cells. > > I can't cache the main one (because it simply doesn't work for me) but > that's not a real problem because the *.php produced file doesn't really > change a lot so I'm not sure that speed increase will be huge. > > On the other side I have some of the internal included files that I would > like to cache because theses internal *.tpl files are fed by database data > and these data doesn't change so often (for example one of them display a > list of news title, but I had news twice a week) > > So my question: I'm looking for a example (a working one preferably) of a > cache for a given template that is included in a main one, because I > absolutely don't understand how it is done. > > Thanks in advance > > Luc > > --- > You are currently subscribed to smarty as: monte@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/ --- You are currently subscribed to smarty as: alain@valain.com 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 (#2521) next »