/** * 渲染品牌管理页面首页 */ public function index() { $value = I('get.value'); if (empty($value)) { $value = 1; } $auto_attr = new AutoattributeModel(); $brand_type = $auto_attr->getAttrBy_Type_Value('brand_type'); $map = array('attr_value' => $value, 'marks' => 0); $Brandlist = $this->lists('Brand', $map); //品牌信息列表 $this->assign('brand_list', $Brandlist); $this->assign('brandvalue', $value); //品牌类型列表 $this->assign('brand_type_list', $brand_type); $this->display(); }
/** * 编辑 */ function edit() { $ParentId = I('get.value'); $id = I('get.id'); $Attribute = new AutoattributeModel(); $Science = new ScienceModel(); $Science_info = $Science->getById($id); //获取父属性 //根据父属性获取子属性 $AttrChild = $Attribute->getByPid($ParentId); //获取父属性 $AttrParent = $Attribute->getParentAttr('science'); $this->assign('science_info', $Science_info[0]); $this->assign('id', $id); $this->assign('AttrParent', $AttrParent); $this->assign('AttrChild', $AttrChild); $this->assign('action', 'edit'); $this->assign('parent_id', $ParentId); $this->display(); }
/** * * 保存新闻信息 */ function save() { $action = I('post.HDaction'); $Notice = D('Notice'); $AutoAttr = new AutoattributeModel(); $id = I('post.HDid'); $data['notice_title'] = I('post.notice_title'); $data['notice_type'] = I('post.notice_type'); $data['notice_discript'] = I('post.notice_descript'); $data['notice_content'] = I('post.notice_content'); $data['notice_type_name'] = $AutoAttr->getAttrName('notice', $data['notice_type']); if ('create' == $action) { $data['creator'] = UID; $data['create_time'] = $this->getCurrentTime(); $data['update_time'] = $this->getCurrentTime(); $vail = $Notice->create($data); if ($vail) { $id = $Notice->add(); if ($id > 0) { $this->success('创建成功', U('Notice/index')); } } else { $this->error($Notice->getError()); } } elseif ('edit' == $action) { $data['update_time'] = $this->getCurrentTime(); $vail = $Notice->create($data); if ($vail) { $result = $Notice->where('id=' . $id . '')->save($data); if ($result > 0) { $this->success('更新成功!', U('Notice/index')); } } else { $this->error($Notice->getError()); } } }