在樣版裡,我們可以透過Smarty預先定義好的變數,以存取PHP中的全域變數(SuperGlobals)
| Smarty 保留變數 | 等同的PHP變數 |
| $smarty.get | $_GET |
| $smarty.post | $_POST |
| $smarty.request | $_REQUEST |
| $smarty.session | $_SESSION |
| $smarty.cookies | $_COOKIE |
| $smarty.env | $_ENV |
| $smarty.server | $_SERVER |
| $smarty.const | 利用define函式定義的常數 |
<{foreach from=$rows item=row key=id name=t}>
<{if $smarty.foreach.t.first}>
<tbody id='sort'>
<{/if}>
<tr id='tr_<{$row.sn}>'>
<td class="text-center"></td>
<td class="text-center"><{$row.date}></td>
<td class="text-center"><{$row.title}></td>
<td class="text-center"><{$row.kind_title}></td>
<td class="text-center">
<{if $row.enable}>
<a href='?op=op_update_enable&sn=<{$row.sn}>&enable=0' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>'><img src='<{$xoops_url}>/modules/<{$DIRNAME}>/images/on.png' /></a>
<{else}>
<a href='?op=op_update_enable&sn=<{$row.sn}>&enable=1' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>'><img src='<{$xoops_url}>/modules/<{$DIRNAME}>/images/off.png' /></a>
<{/if}>
</td>
<td class="text-center">
<a href="?op=op_form&sn=<{$row.sn}>" class="btn btn-success btn-xs"><{$smarty.const._EDIT}></a>
<a href="javascript:op_delete_js(<{$row.sn}>);" class="btn btn-danger btn-xs"><{$smarty.const._DELETE}></a>
</td>
</tr>
<{if $smarty.foreach.t.last}>
</tbody>
<{/if}>
<{/foreach}>