Controlling Cacheability of Plugins' Output
Since Smarty-2.6.0 plugins the cacheability of plugins can be declared when registering them. The third parameter to register_block(), register_compiler_function() and register_function() is called $cacheable and defaults to TRUE which is also the behaviour of plugins in Smarty versions before 2.6.0
When registering a plugin with $cacheable=false the plugin is called everytime the page is displayed, even if the page comes from the cache. The plugin function behaves a little like an {insert} function.
In contrast to {insert} the attributes to the plugins are not cached by default. They can be declared to be cached with the fourth parameter $cache_attrs. $cache_attrs is an array of attribute-names that should be cached, so the plugin-function get value as it was the time the page was written to cache everytime it is fetched from the cache.
Example 14-11. Preventing a whole passage of a template from being cached
where index.tpl is:
|
When reloading the page you will notice that both dates differ. One is "dynamic" one is "static". You can do everything between {dynamic}...{/dynamic} and be sure it will not be cached like the rest of the page.

