/** * Url: /blogs * @param bool|int $id int User id * @return mixed */ public function actionBlogs($id = false) { $query = Post::find()->where(['is_public' => 1, 'content_category_id' => Post::CATEGORY_BLOG]); if ($id) { $query->andWhere(['user_id' => $id]); } $query->orderBy(['created_at' => SORT_DESC]); $postsDataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); return $this->render('@frontend/views/site/index', ['templateType' => 'col2', 'title' => 'Dynamomania.com | Блоги', 'columnFirst' => ['user_comments' => SiteBlock::getUserComments($id), 'content' => ['view' => '@frontend/views/site/blogs', 'data' => compact('postsDataProvider')]], 'columnSecond' => ['best-blogs' => SiteBlock::getBlogPostsByRating(), 'short-news' => SiteBlock::getShortNews()]]); }