Re: [PHPTAL] Cache options from PHP
On Mon, 07 Apr 2008 15:53:56 +0100, Christoph Frick <[EMAIL PROTECTED]> wrote: $phptal->set('cache_duration', "3 h"); // variable's value must be integer ... i hope this is allowed too? No, it's not allowed (I don't want to check syntax at run time). otherwise, the original requeester still has the problem, that template and application logic mix. The unit is just a syntactic sugar. If application needs finer control over cache duration, templates can use seconds as the unit: -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Cache options from PHP
On Mon, Apr 07, 2008 at 03:34:23PM +0100, Kornel Lesinski wrote: > $phptal->set('cache_duration', 3); // variable's value must be integer > ... > $phptal->set('cache_duration', "3 h"); // variable's value must be integer ... i hope this is allowed too? otherwise, the original requeester still has the problem, that template and application logic mix. -- cu pgpbUr2j2qb1b.pgp Description: PGP signature ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Cache options from PHP
On 7 Apr 2008, at 12:11, B. Kamer wrote: Would it be possible to set caching options not from within the template but rather from PHP? I need to be able to do this because the engine that utilizes the template engine decides the caching options? I've added such possiblity — check latest SVN revision (r340). phptal:cache now allows variable name in place of number, so the following will cache for 3 hours: $phptal->set('cache_duration', 3); // variable's value must be integer ... -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Cache options from PHP
Thanks but, this would mean that i still need to set caching properties within the template... I need to set caching options without a need for special markup... setSource is a phptal method, so something like; $instance = new PHPTal(); $templateSource = '' . file_get_contents($tpl_file) . ''; $instance->setSource($templateSource); $result = $instance->execute(); but it also seems a bit wierd. On 7 apr 2008, at 13:40, Werner wrote: Hi! This should be fairly easy. You can set caching as a per-element condition (if I understand your approach correctly) and cache it accordingly by making use of tal:condition. E.g, try something like this: ...in your code: $instance->cache_h3 = true; ...and in your template (note the use of "not" in the second block): ... caching h3 template stuff... ... un-cached h3 template stuff... The only disadvantage to this approach is template markup duplication (if content is not much different between the cached and un-cached blocks). This is a quick-and-dirty way to get it done. Maybe someone has a better idea? Kind Regards, Werner B. Kamer wrote: Hi, just been introduced to phptal as an template engine and am investigating it... Would it be possible to set caching options not from within the template but rather from PHP? I need to be able to do this because the engine that utilizes the template engine decides the caching options? So instead of: ... template ... i need something like: $instance = new PHPTal(); $instance->setTemplate($tpl_file); $instance->setCaching(''3h"); $result = $instance->execute(); thanks Bas ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Cache options from PHP
Hi! This should be fairly easy. You can set caching as a per-element condition (if I understand your approach correctly) and cache it accordingly by making use of tal:condition. E.g, try something like this: ...in your code: $instance->cache_h3 = true; ...and in your template (note the use of "not" in the second block): ... caching h3 template stuff... ... un-cached h3 template stuff... The only disadvantage to this approach is template markup duplication (if content is not much different between the cached and un-cached blocks). This is a quick-and-dirty way to get it done. Maybe someone has a better idea? Kind Regards, Werner B. Kamer wrote: Hi, just been introduced to phptal as an template engine and am investigating it... Would it be possible to set caching options not from within the template but rather from PHP? I need to be able to do this because the engine that utilizes the template engine decides the caching options? So instead of: ... template ... i need something like: $instance = new PHPTal(); $instance->setTemplate($tpl_file); $instance->setCaching(''3h"); $result = $instance->execute(); thanks Bas ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal