getListForCount(); // } $order = 'id desc'; $data_list = $model->getListForPage($map, 1, 3, $order); $builder = new ListBuilder(); $builder = $builder->setMetaTitle('简介管理'); $builder ->setNIDByNode(MODULE_NAME, CONTROLLER_NAME, 'index') // ->addSearchItem('news_name', 'select_text', '单行输入', array('name' => '名称')) ->addTableColumn('belong_to', '模块') ->addTableColumn('content', '内容') ->addTableColumn('right_button', '操作', 'btn') ->setTableDataList($data_list) // 数据列表 ->addRightButton('edit') // 添加编辑按钮 ->display(); } public function edit($id) { if (IS_POST) { parent::autoCheckToken(); $m_id = I('post.id'); $data = I('post.'); $model = D('Introduce'); if (!$m_id) { E('缺少内容ID'); } $ent = $model->getOne($m_id); if (!$ent) { E('不存在内容'); } $ent['content'] = $data['content']; if ($model->createSave($ent) === false) { $this->error($model->getError()); } else { $this->success('修改成功', U('index')); } } else { $model = D('Introduce'); $info = $model->getOne($id); $builder = new FormBuilder(); $builder->setMetaTitle('修改简介') ->setPostUrl(U('edit')) ->setNIDByNode(MODULE_NAME, CONTROLLER_NAME, 'index') ->addFormItem('id', 'hidden', 'ID') // belong_to 不允许修改 ->addFormItem('belong_to', 'text', '模块', '请勿修改此字段') ->addFormItem('content', 'textarea', '内容') ->setFormData($info) ->display(); } } public function forbid() { $ids = I('ids'); if (!$ids) { $this->error('请选择要禁用的数据'); } $r = parent::_forbid($ids); if ($r !== false) { // sysLogs('新闻分类id: ' . $ids . ' 禁用'); $this->success('禁用成功', U(CONTROLLER_NAME . '/index')); } else { $this->error($this->_getError()); } } public function resume() { $ids = I('ids'); if (!$ids) { $this->error('请选择要启用的数据'); } $r = parent::_resume($ids); if ($r !== false) { $this->success('启用成功', U(CONTROLLER_NAME . '/index')); } else { $this->error($this->_getError()); } } public function delete() { $ids = I('ids'); if (!$ids) { $this->error('请选择要删除的数据'); } $r = parent::_del($ids); if ($r === false) { $this->error($this->_getError()); } else { $this->success('删除成功', U(MODULE_NAME . '/' . CONTROLLER_NAME . '/index')); } } }