一、結構
二、商品檔管理
admin_prod.php
<?php
/* 引入檔頭,每支程都會引入 */
require_once 'head.php';
#權限檢查
if($_SESSION['group'] != "admin")redirect_header("index.php", 3000, "您沒有管理員權限!");
#過濾變數,設定預設值
$op = system_CleanVars($_REQUEST, 'op', 'opList', 'string');
$sn = system_CleanVars($_REQUEST, 'sn', '', 'int');
/* 程式流程 */
switch ($op){
#預設動作
default:
$op = "opList";
$_SESSION['returnUrl'] = getCurrentUrl();
opList();
break;
}
/*---- 將變數送至樣版----*/
$smarty->assign("WEB", $WEB);
$smarty->assign("op", $op);
/*---- 程式結尾-----*/
$smarty->display('theme_admin.tpl');
/*---- 函數區-----*/
###############################
# 會員列表
###############################
function opList(){
global $smarty,$db;
}
後台主樣板 theme_admin.tpl
<{elseif $WEB.file_name == "admin_prod.php"}>
<{include file="tpl/admin_prod.tpl"}>
admin_prod.tpl
<{if $op == "opList"}>
<div class="panel panel-primary">
<div class="panel-heading">商品管理</div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>縮圖</th>
<th>日期</th>
<th>標題</th>
<th>排序</th>
<th>精選</th>
<th>啟用</th>
<th class="text-center">
<a href="admin_prod.php?op=opForm" class="btn btn-primary btn-xs">新增</a>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<{/if}>
<{if $op == "opForm"}>
<{/if}>
在「theme_admin.tpl」加一個連結
<li class="list-group-item"><a href="admin_prod.php">商品管理</a></li>
結果
