$this->register_compiler_function('/while', 'smarty_compiler_endwhile');
function smarty_compiler_while($tag_arg, &$smarty) {
$res = $smarty->_compile_if_tag($tag_arg);
preg_match("/<\?php if (.*): \?>/",$res,$token);
return "while " . $token[1] . " {";
}
function smarty_compiler_endwhile($tag_arg, &$smarty) {
return "}";
}
vous pouvez l'utiliser dans vos templates comme suivant:
{assign var="test" value=1}
{while ($test <= 5)}
{assign var="test" value="`$test+1`"}
passage numero {$test}
{/while}
Aucun commentaire:
Enregistrer un commentaire