public function run() { $limit = NewsConfig::model()->findByPk(1, array('select' => 'widget_count')); $limit = $limit->widget_count; $criteria = new CDbCriteria(); $criteria->compare('public', 1); $criteria->limit = $limit; $criteria->order = 'date DESC'; $news = News::model()->findAll($criteria); $this->render('lastnews', array('news' => $news)); return parent::run(); }
/** * view all models. */ public function actionIndex() { $model = NewsConfig::model()->find(); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } if (isset($_POST['NewsConfig'])) { $model->attributes = $_POST['NewsConfig']; if ($model->save()) { Yii::app()->user->setFlash('newsConfig', 'Данные успешно изменены.'); } else { Yii::app()->user->setFlash('newsConfig', 'Ошибка изменения данных!!!.'); } $this->refresh(); } $this->render('index', array('model' => $model)); }
public function init() { $this->config = NewsConfig::model()->find(); }
/** * Lists all models. */ public function actionIndex() { $dataProvider = new CActiveDataProvider('News', array('criteria' => array('condition' => 'public=1', 'order' => 'date DESC'), 'pagination' => array('pageSize' => NewsConfig::model()->findByPk(1)->view_count))); $this->render('index', array('dataProvider' => $dataProvider, 'titleListNews' => $this->config->title, 'folder_upload' => News::FOLDER_UPLOAD)); }