//顯示活動列表 function list_action() { global $xoopsDB, $xoopsTpl; $tbl = $xoopsDB->prefix('actions'); $sql = "SELECT * FROM `{$tbl}` WHERE `enable` ='1' AND `end_date` > now() ORDER BY `end_date` DESC"; $result = $xoopsDB->query($sql) or web_error($sql); $myts = MyTextSanitizer::getInstance(); while ($action = $xoopsDB->fetchArray($result)) { $action['title'] = $myts->htmlSpecialChars($action['title']); $action['content'] = $myts->displayTarea($action['content'], 1, 1, 1, 1, 0); $actions[] = $action; } $xoopsTpl->assign('actions', $actions); include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php"; $sweet_alert = new sweet_alert(); $sweet_alert->render("delete_action", "admin/main.php?op=delete_action&action_id=", 'action_id'); } ``` 2. render()的第一個參數是js的刪除函數名稱,第二個參數則是執行刪除的路徑,最後一個參數是傳入的編號名稱。 3. 編輯 templates/tad\_signup\_index.tpl 樣板,根據身份加入「刪除」按鈕 ``` <{if $isAdmin}> 刪除 編輯 <{/if}> 詳情 ```
<{if $isAdmin}> 刪除 編輯 <{/if}> 詳情 ```
進階搜尋