/** * 公用 */ public function Predecessor() { $data['status'] = 1; $list = $this->db->where($data)->order('sort asc,id asc')->select(); $tree = new \My\Tree($list); $tree->name_field = 'title'; $list = $tree->get_tree('0'); //dump($list);exit; $this->assign('list', $list); }
/** * 列表页 前置 */ public function _before_index() { //获取商品类型存在规格的类型 $specifications = get_goods_type_specifications(); $this->assign('specifications', $specifications); //商品分类 $model = M('Product_category'); $data['status'] = 1; //$data['_string'] = "find_in_set('商城',channel)"; $category = $model->where($data)->select(); $tree = new \My\Tree($category); $category = $tree->get_tree('0'); $this->assign('category', $category); //品牌 $model = M('Brand'); $b_data['status'] = 1; $brands = $model->where($b_data)->select(); $this->assign('brands', $brands); }
/** * 添加信息 前置 */ public function _before_add() { if (!$_POST) { $data['status'] = 1; $list = $this->db->where($data)->order('sort asc,id asc')->select(); $tree = new \My\Tree($list); $list = $tree->get_tree('0'); $this->assign('types', $list); } else { if ($_POST['pid']) { $pdata['id'] = $_POST['pid']; $vo = $this->db->field('id,name')->where($pdata)->find(); $_POST['pname'] = $vo['name']; } else { $_POST['pname'] = '-'; } $_SESSION['pid'] = $_POST['pid'] ? $_POST['pid'] : 0; $_POST['channel'] = implode(',', $_POST['channel']); } }
/** * 公用信息 */ public function Predecessor() { //$flags = $this->get_flags(); $flags = $this->get_moudel_flags(); $this->assign('imgurl', C('IMG_URL')); $this->assign('flags', $flags); $model = D('Classify'); $data['status'] = 1; $list = $model->where($data)->order('sort asc,id desc')->select(); $tree = new \My\Tree($list); $list = $tree->get_tree('0'); $this->assign('types', $list); }
/** * 获取列表信息 */ public function lists() { $model = M('Classify'); $data = array(); if ($_POST['pid']) { $data['pid'] = $_POST['pid']; } $list = $model->where($data)->select(); $tree = new \My\Tree($list); $list = $tree->get_tree('0'); if (IS_AJAX) { echo json_encode($list); } else { return $list; } }