public function actionIndex() { $this->layout = 'main3'; //Yii::$app->view->registerCssFile('/css/animate.min.css'); Yii::$app->view->registerCssFile('/css/swiper.min.css'); //Yii::$app->view->registerJsFile('/js/jquery.min.js'); Yii::$app->view->registerJsFile('/js/swiper.min.js'); //Yii::$app->view->registerJsFile('/js/swiper.animate.min.js'); //Yii::$app->view->registerJsFile('/js/zepto.min.js'); $this->getView()->title = '正晖资本'; $news = News::find()->select('id, title, date')->limit(4)->orderBy('id desc')->where('type in (1, 2, 3)')->all(); $cases = News::find()->select('id, pic')->limit(16)->orderBy('id desc')->where('type = 4')->all(); $frontpages = Frontpage::find()->where(['used' => 1])->all(); return $this->render('index', ['frontpages' => $frontpages, 'news' => $news, 'cases' => $cases]); }
/** * Finds the Frontpage model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Frontpage the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Frontpage::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }