Exemplo n.º 1
0
 public function actionRead($id)
 {
     $model = Post::findByIdOrSlug($id);
     $model->addViewsNumber();
     list($title, $desc, $keys) = $model->getMetaData();
     $this->getView()->setMetaData($title, $desc, $keys);
     return $this->render('view', ["post" => $model]);
 }
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find()->orderBy(['id' => SORT_DESC]), 'pagination' => ['pageSize' => 15]]);
     $this->getView()->setMetaData(\Yii::$app->get("config")->get("app.name"), \Yii::$app->get("config")->get("app.description"), \Yii::$app->get("config")->get("app.keywords"));
     return $this->render('index', ["posts" => $dataProvider->getModels(), "pagination" => $dataProvider->getPagination()]);
 }