-
- require('smarty.class.php');
- $smarty = new smarty;
- $smarty->caching = true;
- function smarty_block_dynamic($param, $content, &$smarty) {
- return $content;
- }
- $smarty->register_block('dynamic', 'smarty_block_dynamic', false);
- $smarty->display('index.tpl');
Copy code
index.tpl Template file:
-
-
page created: {"0"|date_format:"%d %h:%m:%s"}
- {dynamic}
- now is: {"0"|date_format:" %d %h:%m:%s"}
- ... do other stuff...
{/dynamic}
-
Copy code
When this page is reloaded, you will notice that the two dates are different.
One is "dynamic" and the other is "static". You can do anything between {dynamic}...{/dynamic} and be sure it won't be cached like the rest of the page.
The above is an example of partial caching of smarty templates. I hope it will be helpful to everyone.
|