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):
<tal:block tal:condition="cache_h3" phptal:cache="3h">
... caching h3 template stuff...
<tal:block>
<tal:block tal:condition="not:cache_h3" >
... un-cached h3 template stuff...
<tal:block>
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:
<tal:block phptal:cache="3h">
... template ...
<tal:block>
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