$modversion['templates'][1]['file'] = 'tad_honor_index_tpl.html'; $modversion['templates'][1]['description'] = 'index.php的樣板';
$xoopsOption['template_main'] = "tad_honor_index_tpl.html";
$xoopsOption['template_main'] = "tad_honor_view_tpl.html";
$modversion['templates'][2]['file'] = 'tad_honor_view_tpl.html'; $modversion['templates'][2]['description'] = 'view.php的樣板';
<h1>恭賀「<{$students}>」</h1>
<div>
恭喜 <b><{$students}></b> 於 <b><{$date}></b> 榮獲 <b><{$descript}></b>
<{if $teachers}>
<div>指導老師:<{$teachers}></div>
<{/if}>
</div>
<{if $note}>
<p><{$note}></p>
<{/if}>
view.php
$xoopsTpl->assign( "date" , $all['honor_date']) ; $xoopsTpl->assign( "students" , $all['honor_students']) ; $xoopsTpl->assign( "descript" , $all['honor_descript']) ; $xoopsTpl->assign( "teachers" , $all['honor_teachers']) ; $xoopsTpl->assign( "note" , $all['honor_note']) ;
<table style='font-size:11pt;'>
<{foreach item=honor from=$honor}>
<tr>
<td><a href='view.php?honor_sn=<{$hono.honor_sn}>'>
<{$honor.honor_students}></a></td>
<td><{$honor.honor_date}></td>
<td><{$honor.honor_descript}></td>
<td><{$honor.honor_teachers}></td>
</tr>
<{/foreach}>
</table>
<div align='center'><{$bar}></div>
index.php
$i=0;
while($all=$xoopsDB->fetchArray($result)){
//處理部份省略
$main[$i]['honor_sn']=$all['honor_sn'];
$main[$i]['honor_students']=$all['honor_students'];
$main[$i]['honor_date']=$all['honor_date'];
$main[$i]['honor_descript']=$all['honor_descript'];
$main[$i]['honor_teachers']=$all['honor_teachers'];
$i++;
}
$xoopsTpl->assign( "honor" , $main) ;
$xoopsTpl->assign( "bar" , $bar) ;
五、在樣板中使用模組語系常數
若語系中有如下定義:
define("_MI_HONOR_YEAR" , "學年度");
那麼在樣板中就可以用這種方式呼叫該常數:
<{$smarty.const._MI_HONOR_YEAR}>