How to only cache part of a page using Smarty Template (PHP)?
Building view on Zed's answer - if your "dynamic" content has a finite number of permutations, build separate templates for those permutations and fetch()
them based on some variable. Something like:
<html>
<body>
<p>Common content would go here with other Smarty {$variables}.</p>
<p>You could then fetch other content using
{if $var1 eq 'foo'}
{fetch file='/path/to/foo.tpl'}
{elseif $var1 eq 'bar'}
{fetch file='/path/to/bar.tpl'}
{/if}
</body>
</html>
Unless you really want the included files to be cached, you will need to create some kind of exclusion logic to ensure that these subpatterns are not cached.
However, if you have an undefined number of potential dynamic parameters, you may need to simply create HTML in your PHP code and pass it to Smarty as a view variable.
source to share
You can use Smarty insert function.
http://www.smarty.net/manual/en/language.function.insert.php
You create a function that gets called and inserts dynamic content into the page. Useful for shopping carts, for example.