'smarty registerPlugin doesn't work correctly
I have a very simple code, I have simplified my code to help you understand the exact problem
<?php
require_once('theme/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir('theme/site/');
$smarty->setCompileDir('theme/compile');
$smarty->setConfigDir('theme/config');
$smarty->setCacheDir('theme/cache');
$smarty -> plugins_dir = 'theme/libs/plugins/';
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
function reg_combobox($params, $content, &$smarty, &$repeat){
$str="";
$str.="<select>";
$str.="<option value=\"0\" >please select </option>";
for($i=0;$i<2;$i++)
$str.="<option>$i</option>";
$str.="</select>";
return $str;
}
$smarty->registerPlugin('block','mycombobox', 'reg_combobox');
echo $smarty->fetch('index.tpl');
?>
and index.tpl:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
{mycombobox}{/mycombobox}
</body>
</html>
everything looks fine but my browser shoes 2 drop-down lists:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<select><option value="0" >please select </option><option>0</option><option>1</option>
</select>
<select>
<option value="0" >please select </option><option>0</option><option>1</option>
</select>
</body>
</html>
why? what is wrong with my codes?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
