public function actionAdvertising()
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition("t.active=1");
     $criteria->addCondition("t.delete=0");
     $criteria->order = "t.order, t.id DESC";
     $count = Advertising::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = Config::model()->getValueByKey('rowsperpagearticle');
     $pages->applyLimit($criteria);
     $models = Advertising::model()->findAll($criteria);
     $this->pageTitle = 'Rao vặt - ' . Config::model()->getValueByKey('sitetitle');
     $this->metaDescription = Config::model()->getValueByKey('metadescription');
     $this->metaKeywords = Config::model()->getValueByKey('metakeywords');
     $this->render('advertising', array('models' => $models, 'pages' => $pages));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Advertising the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Advertising::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }