public function view($slug = null)
    {
        //Checks if there exists a static page
        $static = StaticPage::get($slug);

        if ($static) {
            $page = new Entity(array_merge([
                'category' => new Entity(['slug' => null, 'title' => null]),
                'title' => StaticPage::title($slug),
                'subtitle' => null,
            ], compact('slug')));

            $this->set(compact('page'));

            return $this->render($static);
        }

        $slug = rtrim($slug, '/');
        $page = $this->Pages->findActiveBySlug($slug)
            ->contain([$this->Pages->Categories->getAlias() => ['fields' => ['title', 'slug']]])
            ->cache(sprintf('view_%s', md5($slug)), $this->Pages->getCacheName())
            ->firstOrFail();

        $this->set(compact('page'));
    }
public function view($slug = null)
    {
        //Checks if there exists a static page
        $static = StaticPage::get($slug);

        if ($static) {
            $page = new Entity(array_merge([
                'category' => new Entity(['slug' => null, 'title' => null]),
                'title' => StaticPage::title($slug),
                'subtitle' => null,
            ], compact('slug')));

            $this->set(compact('page'));

            return $this->render($static);
        }

        $slug = rtrim($slug, '/');
        $page = $this->Pages->findActiveBySlug($slug)
            ->contain([$this->Pages->Categories->getAlias() => ['fields' => ['title', 'slug']]])
            ->cache(sprintf('view_%s', md5($slug)), $this->Pages->getCacheName())
            ->firstOrFail();

        $this->set(compact('page'));
    }
public function view ( $ slug = null ) { //Checks if there exists a static page $ static = StaticPage :: get ( $ slug ) ; if ( $ static ) { $ page = new Entity ( array_merge ( [ 'category' => new Entity ( [ 'slug' => null , 'title' => null ] ) , 'title' => StaticPage :: title ( $ slug ) , 'subtitle' => null , ] , compact ( 'slug' ) ) ) ; $ this -> set ( compact ( 'page' ) ) ; return $ this -> render ( $ static ) ; } $ slug = rtrim ( $ slug , '/' ) ; $ page = $ this -> Pages -> findActiveBySlug ( $ slug ) -> contain ( [ $ this -> Pages -> Categories -> getAlias ( ) => [ 'fields' => [ 'title' , 'slug' ] ] ] ) -> cache ( sprintf ( 'view_%s' , md5 ( $ slug ) ) , $ this -> Pages -> getCacheName ( ) ) -> firstOrFail ( ) ; $ this -> set ( compact ( 'page' ) ) ; }
Views page.

It first checks if there's a static page, using all the passed
arguments.
Otherwise, it checks for the page in the database, using that slug.

Static pages must be located in `APP/View/StaticPages/`.
@param string $slug Page slug
@return \Cake\Network\Response|void
@uses MeCms\Utility\StaticPage::get()
@uses MeCms\Utility\StaticPage::title()
Views page .