/** * @param $name * @return string * @throws NotFoundHttpException */ public function actionShow($name) { $post = $this->findModelByAlias($name); //按类型显示 $comments = Comment::findAll(['pid' => $post->id]); $post->updateCounters(['view_count' => 1, 'comment_count' => count($comments) - $post->comment_count]); return $this->render('view', ['post' => $post, 'comments' => $comments, 'hide_post' => array('passed' => [], 'info' => '', 'captcha' => 'hide-captcha', 'pwd' => 'hide-pwd')]); }