Esempio n. 1
0
 public function loadModel()
 {
     if ($this->_model == null) {
         if (isset($_GET['category'])) {
             $this->_model = category_entity::model()->findByAttributes(array('category_SEF' => $_GET['category']));
         }
         if ($this->_model == null) {
             throw new CHttpException(404, "The requested page does not exist!");
         }
     }
     return $this->_model;
 }
Esempio n. 2
0
 public function actionOrder()
 {
     if (Yii::app()->request->isPostRequest && isset($_POST['Order'])) {
         $models = explode(',', $_POST['Order']);
         for ($i = 0; $i < sizeof($models); $i++) {
             if ($model = category_entity::model()->findbyPk($models[$i])) {
                 $model->category_order = $i;
                 $model->save();
             }
         }
     } else {
         if ($_GET['id']) {
             $condition = "category_parent_ID={$_GET['id']}";
         } else {
             //root category sort
             $condition = "category_level=1";
         }
         $dataProvider = new CActiveDataProvider('category_entity', array('pagination' => false, 'criteria' => array('condition' => $condition, 'order' => 'category_order ASC, category_ID DESC')));
         $this->htmlOption = array('class' => 'icon-head head-products', 'header' => "分类排序", 'button' => array());
         $this->render('order', array('dataProvider' => $dataProvider));
     }
 }