public function add()
 {
     $model = new \Model\CategoryModel();
     if (IS_POST) {
         if ($data = $model->create(I('post.'), 1)) {
             if ($model->add($data)) {
                 $this->success('添加商品栏目成功', U('showlist'), 1);
                 exit;
             } else {
                 $this->error('添加商品栏目失败');
             }
         } else {
             $this->error($model->getError());
         }
     }
     //取出商品栏目
     $cat_list = $model->getTree();
     $this->assign('cat_list', $cat_list);
     $this->display();
 }
Exemple #2
0
 public function catadd()
 {
     $category = new \Model\CategoryModel();
     if (!empty($_POST)) {
         //收集表单数据
         $info = $category->create();
         $result = $category->add($info);
         if ($result) {
             //跳转
             $this->redirect('category', array(), 2, '添加分类成功');
         }
     }
     $par_info = $category->where("parent_id=0")->select();
     $this->assign('par_info', $par_info);
     $this->display();
 }