public function details($contentTypeSlug, $contentSlug)
    {
        $this->loadModel('Content.Contents');
        $conditions = [
            'Contents.slug' => $contentSlug,
            'Contents.content_type_slug' => $contentTypeSlug,
        ];

        if (!$this->request->is('userAdmin')) {
            $conditions['Contents.status >'] = 0;
        }

        $content = $this->Contents->find()
            ->where($conditions)
            ->contain(['ContentTypes', 'Roles'])
            ->first();

        if (!$content) {
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        } elseif (!$content->isAccessibleByUser()) {
            throw new ForbiddenException(__d('content', 'You have not sufficient permissions to see this page.'));
        }

        if (!empty($content->language) && $content->language != I18n::locale()) {
            if ($redirect = $this->_calculateRedirection($content)) {
                $this->redirect($redirect);

                return $this->response;
            }
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        }

        // Post new comment logic
        if ($content->comment_status > 0) {
            $content->set('comments', $this->Contents->find('comments', ['for' => $content->id]));
            $this->Comment->config('visibility', $content->comment_status);
            $this->Comment->post($content);
        }

        $this->set('content', $content);
        $this->viewMode('full');
    }
public function details($contentTypeSlug, $contentSlug)
    {
        $this->loadModel('Content.Contents');
        $conditions = [
            'Contents.slug' => $contentSlug,
            'Contents.content_type_slug' => $contentTypeSlug,
        ];

        if (!$this->request->is('userAdmin')) {
            $conditions['Contents.status >'] = 0;
        }

        $content = $this->Contents->find()
            ->where($conditions)
            ->contain(['ContentTypes', 'Roles'])
            ->first();

        if (!$content) {
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        } elseif (!$content->isAccessibleByUser()) {
            throw new ForbiddenException(__d('content', 'You have not sufficient permissions to see this page.'));
        }

        if (!empty($content->language) && $content->language != I18n::locale()) {
            if ($redirect = $this->_calculateRedirection($content)) {
                $this->redirect($redirect);

                return $this->response;
            }
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        }

        // Post new comment logic
        if ($content->comment_status > 0) {
            $content->set('comments', $this->Contents->find('comments', ['for' => $content->id]));
            $this->Comment->config('visibility', $content->comment_status);
            $this->Comment->post($content);
        }

        $this->set('content', $content);
        $this->viewMode('full');
    }
public function details ( $ contentTypeSlug , $ contentSlug ) { $ this -> loadModel ( 'Content.Contents' ) ; $ conditions = [ 'Contents.slug' => $ contentSlug , 'Contents.content_type_slug' => $ contentTypeSlug , ] ; if ( ! $ this -> request -> is ( 'userAdmin' ) ) { $ conditions [ 'Contents.status >' ] = 0 ; } $ content = $ this -> Contents -> find ( ) -> where ( $ conditions ) -> contain ( [ 'ContentTypes' , 'Roles' ] ) -> first ( ) ; if ( ! $ content ) { throw new ContentNotFoundException ( __d ( 'content' , 'The requested page was not found.' ) ) ; } elseif ( ! $ content -> isAccessibleByUser ( ) ) { throw new ForbiddenException ( __d ( 'content' , 'You have not sufficient permissions to see this page.' ) ) ; } if ( ! empty ( $ content -> language ) && $ content -> language != I18n :: locale ( ) ) { if ( $ redirect = $ this -> _calculateRedirection ( $ content ) ) { $ this -> redirect ( $ redirect ) ; return $ this -> response ; } throw new ContentNotFoundException ( __d ( 'content' , 'The requested page was not found.' ) ) ; } // Post new comment logic if ( $ content -> comment_status > 0 ) { $ content -> set ( 'comments' , $ this -> Contents -> find ( 'comments' , [ 'for' => $ content -> id ] ) ) ; $ this -> Comment -> config ( 'visibility' , $ content -> comment_status ) ; $ this -> Comment -> post ( $ content ) ; } $ this -> set ( 'content' , $ content ) ; $ this -> viewMode ( 'full' ) ; }
Content's detail page.

@param string $contentTypeSlug Content's type-slug. e.g. `article`, `basic-page`
@param string $contentSlug Content's slug. e.g. `this-is-an-article`
@return \Cake\Network\Response|null
@throws \Content\Error\ContentNotFoundException When content is not found
@throws \Cake\Network\Exception\ForbiddenException When user can't access
this content due to role restrictions
Content s detail page .