Re: [SMARTY] Caching parts of a page
| From: | Ivo Jansch | Date: | Tue, 23 Apr 2002 07:42:43 +0000 |
| Subject: | Re: [SMARTY] Caching parts of a page | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3847@lists.php.net to get a copy of this message | ||
Hi,
Monte Ohrt wrote:
It would be nice to automatically have certain functions cached or not. To really do it right would take bit of work, it isn't trivial to do. It would probably take some major changes to the parsing engine. This will probably happen eventually, but not anytime soon.I have it working in my application, but you probably wouldn't like the implementation: I have a wrapper function for registering functions. Besides registering the funtion in Smarty, it keeps some metadata like whether it's a dynamic function etc. Then I use the 'default tag handler' patch (which I've sent you before) to handle *all* my 'application tags'. When Smarty runs, the default tag handler determines whether the tag encountered was a dynamic one. If it is, it returns the tag itself, so the tag is *not rendered*. So the result from Smarty->fetch is actually an almost completely rendered page, only the dynamic tags are still in place. This page is cached. After the fetch() (which could have been rendered on the fly or pulled out of the cache, that doesn't matter any more), I have a 'second pass' renderer which handles the tags that were still left (much like the way you handle the insert handler). The final stage is a 'postfilter' (not the postfilter feature from smarty, because I need it to operate on the completely rendered template) that inserts some necessary javascript and/or metatags in the header, that were set by the dynamic tags. Greetings, Ivo -- Ivo Jansch <ivo@ibuildings.nl> ibuildings.nl BV - information technology http://www.ibuildings.nl