{html_options options=$cust_options selected=$customer_id}
实例:
后台文件:out.phprequire('Smarty.php.class');
$smarty = new Smarty;
$smarty->assign('cust_options', array(
1001 => 'Joe Schmoe',
1002 => 'Jack Smith',
1003 => 'Jane Johnson',
1004 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('out.tpl');
模板文件:out.tpl
{html_options options=$cust_options selected=$customer_id}
注意说明:$customer_id一定是数组中某个元素的键名,不是元素值
模板解析之后:
Joe Schmoe
Jack Smith
Jane Johnson
Charlie Brown