smarty
smarty copied to clipboard
default plugin handler not called for close tag of block plugins
The subject says it all. In previous versions of smarty (3.1.16) the defaultPlugin handler was called for the opening tag, and closing tag of block plugins.... not so in 3.1.27
The defaultPluginHandler should be called for 'blockpluginclose' but it is not.
<?php
include_once('smarty-3.1.27/libs/Smarty.class.php');
define('SMARTY_COMPILE_DIR',getcwd().'/tmp/templates_c');
define('SMARTY_CACHE_DIR',getcwd().'/tmp/cache');
function myDefaultPlugin($params,$template)
{
return null;
}
function defaultPluginHandler($name,$type,$template,&$callback,&$script,&$cachable)
{
echo __FUNCTION__."($name,$type)\n";
$callback = 'myDefaultPlugin';
$cachable = false;
return TRUE;
}
$smarty = new Smarty();
$smarty->setCompileDir(SMARTY_COMPILE_DIR);
$smarty->setCacheDir(SMARTY_CACHE_DIR);
$smarty->addTemplateDir(getcwd().'/templates');
$smarty->addConfigDir(getcwd().'/configs');
$smarty->registerDefaultPluginHandler('defaultPluginHandler');
$rsrc = 'string:{funcplugin}{blockplugin}some text{/blockplugin}';
$smarty->display($rsrc);
?>
Your example does fail in all Smarty versions. The default plugin handler is called looping trough all plugin types. You must check in your handler if the $name shall match with $type. Your return a callback always for the first $type, which is function. So {blockplugin} does not get registered as a blockplugin.
See http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl