How can I unload or disallow smarty core plugins from a template when using $smarty->fetch('mytemplate.tpl')
method
For example the template mytemplate.tpl
contains {html_options} and {html_table}
When using $smarty->fetch('mytemplate.tpl')
only the {html_options} should be parsed by smarty, but {html_table} not
removing the function.html_table.php
from plugin folder is not an option as it is still in use by another $smarty->fetch()
call
A possible solutions is to extend from the
Smarty_Security
class and enable securty by using the method$smarty->enableSecurity($instanceOfClass)
Once the fetch method has been called ,
disableSecurity
method do the trick to reenable allplugins/tags/modifiers
again.Unfortunately when enableSecurity is used and forbidden functions are used an Exception is thrown
An alternative is to replace all tags/variables/... you want to disallow with {literal}{forbiddenTags}{/literal} by using
preg_replace
before calling$smarty->fetch([...])
Example
More details about the Security class here: http://www.smarty.net/docs/en/advanced.features.tpl