使用说明:
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>