default:
# ---- 目前網址 ----
$_SESSION['return_url'] = getCurrentUrl();
$op = "opList";
opList();
break;
```
2. 傳入變數處理 ```
/*-----------執行動作判斷區----------*/
include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php');
$op = system_CleanVars($_REQUEST, 'op', '', 'string');
$sn = system_CleanVars($_REQUEST, 'sn', '', 'int');
```
3. 引入上傳物件 ```
#引入上傳物件
include_once XOOPS_ROOT_PATH . "/modules/ugm_tools2/ugmUpFiles3.php";
```
二、函數
1. opList ```
#商品列表
function opList() {
global $xoopsDB, $xoopsTpl,$module_name;
#---- 過濾讀出的變數值 ----
$myts = MyTextSanitizer::getInstance();
$sql = "select a.sn,a.title,b.title as kind_title
from " . $xoopsDB->prefix("cnu_show_prod") . " as a
left join " . $xoopsDB->prefix("cnu_show_kind") . " as b on a.kind=b.sn
where a.enable='1'
order by a.`sort` desc,a.`date` desc
"; //die($sql);
//getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項);
$p_count = 9;
$PageBar = getPageBar($sql, $p_count, 10);
$bar = $PageBar['bar'];
$sql = $PageBar['sql'];
$total = $PageBar['total'];
$bar = $total > $p_count ? $bar : "";
$xoopsTpl->assign("bar", $bar);
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, web_error());
#----單檔圖片上傳
$subdir = "prod"; //子目錄(前後不要有 / )
$ugmUpFiles = new ugmUpFiles($module_name, $subdir); //實體化
$col_name = "prod"; //資料表關鍵字
$thumb = false ; //顯示縮圖
$rows = array();
while ($row = $xoopsDB->fetchArray($result)) {
$row['sn'] = intval($row['sn']);
$row['title'] = $myts->addSlashes($row['title']);
$row['kind_title'] = $myts->addSlashes($row['kind_title']);
$col_sn = $row['sn']; //關鍵字流水號
$row['prod'] = $ugmUpFiles->get_rowPicSingleUrl($col_name,$col_sn,$thumb);
#-----------------------------------
$rows[] = $row;
}
$main['rows'] = $rows;
$main['title'] = "商品展示";
$xoopsTpl->assign("main", $main);
}
```
三、樣板
```
<{if $op=="opList"}>
<{$main.title}>
<{foreach from=$main.rows item=row}>
>
<{$row.title}>
<{$row.kind_title}>
<{/foreach}>
<{$bar}>
<{/if}>
```