Пример #1
0
 public function actionIndex()
 {
     if (!empty($this->arrSystem)) {
         $this->pageTitle = "Trang chủ - " . $this->arrSystem->title;
     }
     // Hinh anh trinh dien
     $criteria = new CDBCriteria();
     $criteria->addCondition("is_product = 3");
     $arrImage = Slides::model()->findAll($criteria);
     // Linh vuc kinh doanh
     $criteria = new CDBCriteria();
     $criteria->addCondition("category_news_id = 1");
     $criteria->limit = 3;
     $arrNew = News::model()->findAll($criteria);
     // tin tuc noi bat
     $criteria = new CDBCriteria();
     $criteria->addCondition("category_news_id != 1");
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $arrNewSpecial = News::model()->findAll($criteria);
     // hinh anh noi bat
     $criteria = new CDBCriteria();
     $criteria->addCondition("is_product = 1");
     $criteria->order = 'id DESC';
     $criteria->limit = 8;
     $arrImageSpecial = Slides::model()->findAll($criteria);
     $this->render("index", array('arrImage' => $arrImage, 'arrNew' => $arrNew, 'arrNewSpecial' => $arrNewSpecial, 'arrImageSpecial' => $arrImageSpecial));
 }
Пример #2
0
 public function actionIndex($id = null)
 {
     if (!empty($this->arrSystem)) {
         $this->pageTitle = "Hình ảnh - " . $this->arrSystem->title;
     }
     $criteria = new CDBCriteria();
     $title = "";
     if ($id == null) {
         $criteria->addCondition("is_product = 1");
         $title = "Hình ảnh hoạt động";
     } else {
         if ($id == 2) {
             $criteria->addCondition("is_product = 2");
             $title = "Sản phẩm mới";
         } else {
             throw new CHttpException(404, 'Không tìm thấy trang!.');
         }
     }
     $countItem = Slides::model()->count($criteria);
     $pages = new CPagination($countItem);
     $pages->setPageSize(12);
     $pages->applyLimit($criteria);
     $arrNew = Slides::model()->findAll($criteria);
     $arrImage = Slides::model()->findALl($criteria);
     $this->render("index", array('arrImage' => $arrImage, 'item_count' => $countItem, 'page_size' => 12, 'pages' => $pages, 'title' => $title));
 }
Пример #3
0
 public function loadModel($id)
 {
     $model = Slides::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #4
0
 public function actionIndex()
 {
     $this->pageTitle = $this->dataSystem->title;
     // Dang ky Internet
     $criInternet = new CDBCriteria();
     $criInternet->addCondition("category_news_id = 1");
     $criInternet->order = "id DESC";
     $criInternet->limit = 3;
     $arrInternet = News::model()->findAll($criInternet);
     //Dang ky cap quang
     $criOptical = new CDBCriteria();
     $criOptical->addCondition("category_news_id = 2");
     $criOptical->order = "id DESC";
     $criOptical->limit = 3;
     $arrOptical = News::model()->findAll($criOptical);
     //Store
     $criStore = new CDBCriteria();
     $criStore->addCondition("category_news_id = 6");
     $criStore->order = "id DESC";
     $criStore->limit = 3;
     $arrStore = News::model()->findAll($criStore);
     //CA
     $criCa = new CDBCriteria();
     $criCa->addCondition("category_news_id = 3");
     $criCa->order = "id DESC";
     $criCa->limit = 3;
     $arrCa = News::model()->findAll($criCa);
     //Sim - Card
     $criSimCard = new CDBCriteria();
     $criSimCard->addCondition("category_news_id = 4");
     $criSimCard->order = "id DESC";
     $criSimCard->limit = 3;
     $arrSimCard = News::model()->findAll($criSimCard);
     //TV
     $criTv = new CDBCriteria();
     $criTv->addCondition("category_news_id = 7");
     $criTv->order = "id DESC";
     $criTv->limit = 3;
     $arrTv = News::model()->findAll($criTv);
     /*Pictures*/
     $criPic = new CDbCriteria();
     $criPic->addCondition("album_id = 2");
     $criPic->order = "id DESC";
     $criPic->limit = 10;
     $arrPic = Images::model()->findAll($criPic);
     /*Slider*/
     $criBanner = new CDbCriteria();
     $criBanner->order = "id DESC";
     $criBanner->limit = 5;
     $arrBanner = Slides::model()->findAll($criBanner);
     /*Links web*/
     $arrLink = Links::model()->find();
     $this->render("index", array('arrBanner' => $arrBanner, 'arrInternet' => $arrInternet, 'arrOptical' => $arrOptical, 'arrStore' => $arrStore, 'arrCa' => $arrCa, 'arrSimCard' => $arrSimCard, 'arrTv' => $arrTv, 'arrLink' => $arrLink));
 }
Пример #5
0
 public function actionDelete($id)
 {
     $model = Slides::model()->findByPk($id);
     if ($model == null) {
         $this->redirect(PIUrl::createUrl('/admin/slides/index/'));
     }
     $name = $model->attributes['image'];
     $this->loadModel($id)->delete();
     if (file_exists(Yii::app()->basePath . '/upload/images/' . $name) && $name->image != '') {
         unlink(Yii::app()->basePath . '/upload/images/' . $name);
     }
     Yii::app()->user->setFlash('success', translate('Xóa thành công.'));
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     $this->redirect(PIUrl::createUrl('/admin/slides'));
 }
Пример #6
0
 public function actionIndex($alias)
 {
     /*Get news by alias*/
     $category = CategoriesNews::model()->findByAttributes(array('alias' => $alias));
     if ($category === null) {
         throw new CHttpException(404, 'Không tìm thấy trang');
     }
     $this->pageTitle = $category->name . ($category->title ? ' - ' . $category->title : '');
     $this->description = $category->description;
     $this->dataSystem->keyword = $category->keyword;
     $criteria = new CDbCriteria();
     $criteria->addCondition("category_news_id = " . $category['id']);
     $criteria->order = "id DESC";
     $count = News::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->setPageSize($this->pageSize);
     $pages->applyLimit($criteria);
     /*Slider*/
     $criBanner = new CDbCriteria();
     $criBanner->order = "id DESC";
     $criBanner->limit = 5;
     $arrBanner = Slides::model()->findAll($criBanner);
     $this->render('index', array('arrBanner' => $arrBanner, 'model' => News::model()->findAll($criteria), 'page_size' => $this->pageSize, 'count' => $count, 'pages' => $pages, 'category' => $category));
 }