使用說明:
1、回復的內容還是需要自己建表存儲起來;
2、通過 Module.php 文件將回復內容相關的操作封裝起來
最終效果圖:

示例:
<?php /** * * @url http://www.we7.cc/ */ defined('IN_IA') or exit('Access Denied'); class Dayu_smsModule extends WeModule { const TABLE_REPLY = '表名'; // 關鍵字回復頁內容展示 public function fieldsFormDisplay($rid = 0) { load ()->func ( 'tpl' ); global $_W; $reply = pdo_get(self::TABLE_REPLY, array('uniacid' => $_W['uniacid'])); include $this->template('form'); } // 驗證提交內容是否正確 public function fieldsFormValidate($rid = 0) { global $_GPC; if (empty ($_GPC['title'])) { return '請先添加標題'; } if (empty ($_GPC['description'])) { return '請先添加描述'; } if (empty ($_GPC['icon'])) { return '圖標不能為空'; } return ''; } // 提交關鍵字回復的內容 public function fieldsFormSubmit($rid) { global $_GPC, $_W; $data = array( 'rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'description' => $_GPC['description'], 'icon' => $_GPC['icon'], ); if (!empty(pdo_get(self::TABLE_REPLY, array('rid' => $rid, 'uniacid' => $_W['uniacid'])))) { pdo_update(self::TABLE_REPLY, $data, array('rid' => $rid, 'uniacid' => $_W['uniacid'])); } else { $data['create_time'] = time(); pdo_insert(self::TABLE_REPLY, $data); } } //規則刪除時調用 public function ruleDeleted($rid) { pdo_delete(self::TABLE_REPLY, array ('rid' => $rid)); } }
2、template/form.html
<div class="panel panel-default"> <div class="panel-heading">設置關鍵字回復 <span style="color: red">(確認后,務刪除)</span></div> <div class="panel-body"> <div class="form-group"> <label for="title" class="control-label col-sm-2">標題</label> <div class="col-sm-9"> <input type="text" class="form-control" name="title" id="title" value="{$reply['title']}"> </div> </div> <div class="form-group"> <label for="description" class="control-label col-sm-2">描述</label> <div class="col-sm-9"> <input type="text" class="form-control" name="description" id="description" value="{$reply['description']}"> </div> </div> <div class="form-group"> <label for="icon" class="control-label col-sm-2">ICON</label> <div class="col-sm-9"> {php echo tpl_form_field_image('icon', $reply['icon'])} </div> </div> </div> </div>
