开发者

Smarty caching problems with nested templates

I have a problem in caching in nested templates in Smarty 3. It seems that when I do an {include} Smarty ignores the caching settings of the caller template. For example, supposing smarty cache has been enabled in the controller:

In template1.tpl:

{include file='template2.tpl' nocache}

In template2.tpl:

{include file='template3.tpl'}

In template3.tpl

{$smarty.now}

The {$smarty.now} value displayed on page is, until the cache is not cleared,开发者_StackOverflow中文版 always equal to the time of the first page visualization, although the first subtemplate is forced to be not cached. This is an annoying problem for me, since I need to control caching settings of all the content of template2.tpl and its subtemplates from template1.tpl.

Are there elegant workarounds?


Smarty does not cache content of template2 (move {$smarty.now} their), but it does cache template3. Include it with nocache too.

I experienced the same problem and I redesign my template, so I'm able to cache most of it and only the parts without need of caching I surrounded with {nocache} content {/nocache}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜