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 = '<tal:block phptal:cache="3h">' . file_get_contents($tpl_file) . '</tal:block>';
$result = $instance->execute();

but it also seems a bit wierd.

On 7 apr 2008, at 13:40, Werner wrote:

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: 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:condition="not:cache_h3" >
  ... 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,

B. Kamer wrote:

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 ...

i need something like:

$instance = new PHPTal();

$result = $instance->execute();



PHPTAL mailing list

PHPTAL mailing list

PHPTAL mailing list

Reply via email to