case "opShow":
opShow($sn);
break;
```
二、函數
1. opShow($sn) ```
#單筆顯示
function opShow($sn = "") {
global $xoopsDB,$xoopsTpl,$module_name;
if (!$sn) {
redirect_header(XOOPS_URL, 3, "資料錯誤!!");
}
#---- 過濾讀出的變數值 ----
$myts = MyTextSanitizer::getInstance();
//sn kind kind_gallery title summary content price amount enable date sort
$sql = "select a.*,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.sn='{$sn}' and a.enable='1'
"; //die($sql);
$result = $xoopsDB->query($sql) or redirect_header(XOOPS_URL, 3, web_error());
$row = $xoopsDB->fetchArray($result);
#-----------------------------------------------------
if (!$row) {
redirect_header(XOOPS_URL, 3, "資料錯誤!!");
}
#計數器+1
InsertCounteAddOne($row['sn'], "cnu_show_prod"); //ugm_tools2/ugmTools.php
#-----------------------------------------------------
//以下會產生這些變數: a.sn,a.kind,a.title,a.url,a.content,b.file_name,b.sub_dir
$row['sn'] = intval($row['sn']);
$row['kind'] = intval($row['kind']);
#一般文字
$row['title'] = $myts->htmlSpecialChars($row['title']);
$row['date'] = intval($row['date']);
#日期
$row['date'] = date("Y-m-d", xoops_getUserTimestamp($row['date'])); //從資料庫撈出
$row['counter'] = intval($row['counter']);
$row['kind_title'] = $myts->htmlSpecialChars($row['kind_title']);
$row['youtube'] = $myts->htmlSpecialChars($row['youtube']);//大類名稱
#大量文字,
$html = 0;
$br = 1;
$row['summary'] = $myts->displayTarea($row['summary'], $html, 1, 0, 1, $br);
#大量文字,編輯器
$html = 1;
$br = 0;
$row['content'] = $myts->displayTarea($row['content'], $html, 1, 0, 1, $br);
#----單檔圖片上傳
$subdir = "prod"; //子目錄(前後不要有 / )
$ugmUpFiles = new ugmUpFiles($module_name, $subdir); //實體化
$col_name = "prod"; //資料表關鍵字
$thumb = false ; //顯示縮圖
$col_sn = $row['sn']; //關鍵字流水號
$row['prod'] = $ugmUpFiles->get_rowPicSingleUrl($col_name,$col_sn,$thumb);
#-----------------------------------------------------
#型錄
#上傳pdf型錄
$multiple = false;
$col_name = "prodPdf";
$ugmUpFiles->set_col($col_name, $row['sn']);
$row['pdf'] = $ugmUpFiles->get_rowFileSingleUrl($col_name, $row['sn']);
#-----------------------------------------------------
$xoopsTpl->assign("row", $row);
#-----------------------------------------------------
}
```
三、樣板
1. templates/cnu\_show\_index.tpl ```
<{if $op == "opShow"}>
<{$row.title}>
<{if $row.pdf}>
型錄
<{/if}>
<{if $row.youtube}>
<{/if}>
<{if $row.youtube}>
<{/if}>
<{/if}>
```