Re: Question about selective caching.
| From: | Monte Ohrt | Date: | Fri, 11 Jan 2002 16:30:13 +0000 |
| Subject: | Re: Question about selective caching. | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2520@lists.php.net to get a copy of this message | ||
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/