public function actionShow($id = null)
    {
        if (!is_numeric($id) || $id < 1) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $post = Post::find()->where(['id' => $id])->limit(1)->one();
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $url = [
            'forum/thread',
            'cid' => $post->thread->category_id,
            'fid' => $post->forum_id,
            'id' => $post->thread_id,
            'slug' => $post->thread->slug
        ];

        try {
            $count = (new Query)->from(Post::tableName())->where([
                    'and',
                    ['thread_id' => $post->thread_id],
                    ['<', 'id', $post->id]
                ])->count();
            $page = floor($count / 10) + 1;
            if ($page > 1) {
                $url['page'] = $page;
            }
            $url['#'] = 'post' . $post->id;
            return $this->redirect($url);
        } catch (Exception $e) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }
    }
public function actionShow($id = null)
    {
        if (!is_numeric($id) || $id < 1) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $post = Post::find()->where(['id' => $id])->limit(1)->one();
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $url = [
            'forum/thread',
            'cid' => $post->thread->category_id,
            'fid' => $post->forum_id,
            'id' => $post->thread_id,
            'slug' => $post->thread->slug
        ];

        try {
            $count = (new Query)->from(Post::tableName())->where([
                    'and',
                    ['thread_id' => $post->thread_id],
                    ['<', 'id', $post->id]
                ])->count();
            $page = floor($count / 10) + 1;
            if ($page > 1) {
                $url['page'] = $page;
            }
            $url['#'] = 'post' . $post->id;
            return $this->redirect($url);
        } catch (Exception $e) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }
    }
public function actionShow ( $ id = null ) { if ( ! is_numeric ( $ id ) || $ id < 1 ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the post you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ post = Post :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ post ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the post you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ url = [ 'forum/thread' , 'cid' => $ post -> thread -> category_id , 'fid' => $ post -> forum_id , 'id' => $ post -> thread_id , 'slug' => $ post -> thread -> slug ] ; try { $ count = ( new Query ) -> from ( Post :: tableName ( ) ) -> where ( [ 'and' , [ 'thread_id' => $ post -> thread_id ] , [ '<' , 'id' , $ post -> id ] ] ) -> count ( ) ; $ page = floor ( $ count / 10 ) + 1 ; if ( $ page > 1 ) { $ url [ 'page' ] = $ page ; } $ url [ '#' ] = 'post' . $ post -> id ; return $ this -> redirect ( $ url ) ; } catch ( Exception $ e ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the post you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } }
Direct link for the post of given ID.
@param int $id
@return Response
Direct link for the post of given ID .