Jill 筆記
:::
:::
所有書籍
「Xoops新物件寫法」目錄
MarkDown
1-1 流程
1. 前置作業
1-1 流程
2. 列出所有活動
3. 新增活動表單
3-1 新增到資料庫
3-2 編輯活動表單
4. 刪除活動
5. 修改前台首頁
3. 新增活動表單
Xoops新物件寫法 ========== 1. ### [action/AdminAction.class.php](https://github.com/tnjaile/ck_signup/commit/cb9231a9b428eaae7b9346d5641832ac5b0d0412#diff-0ece6698acedde7d0cebc5f0184eee02 "action/AdminAction.class.php") 引入Model ```php class AdminAction extends Action { private $_action = null; public function __construct() { parent::__construct(); $this->_action = new ActionsModel(); } //載入資訊 public function main() { $_AllAction = $this->_action->findAll(); $this->_tpl->assign('AllAction', $_AllAction); $this->_tpl->assign('now_op', 'action_list'); $this->_tpl->assign('action', $_SERVER["PHP_SELF"]); } } ``` ### 2. [model/ActionsModel.class.php](https://github.com/tnjaile/ck_signup/commit/cb9231a9b428eaae7b9346d5641832ac5b0d0412#diff-3bb78de405a79c29f299a3eb70c5095f "model/ActionsModel.class.php") ```php // 欄位檢查 // $this->_check = new ActionsCheck(); ``` 暫時註記欄位檢查物件 3. [templates/op\_action\_list.tpl](https://github.com/tnjaile/ck_signup/commit/cb9231a9b428eaae7b9346d5641832ac5b0d0412#diff-0939e8eb0a243cec066da0581b7d97a0 "templates/op_action_list.tpl") ```php <{if $AllAction}>
活動列表
(共 <{$AllAction|@count}> 個活動)
活動日期
活動名稱
截止日期
功能
<{foreach from=$AllAction item=data}>
<{$data.action_date}>
<{if $data.enable!=1}>
已關閉
<{/if}>
<{$data.title}>
<{$data.end_date}>
<{if $xoops_isadmin}>
刪除
編輯
<{/if}>
<{/foreach}>
<{$smarty.const._TAD_ADD}>
<{else}>
<{if $smarty.session.ck_signup_adm}>
<{$smarty.const._TAD_ADD}>
<{else}>
<{$smarty.const._TAD_EMPTY}>
<{/if}>
<{/if}> ``` 4. 畫面 ![](http://120.115.2.101/~jaile/uploads/tad_book3/image/jillbase03.png)