CakePHP3 Tutorial

Next: Building a RSS feed with CakePHP3 UP: TOC

Out website is required to support Desktop Browsers and Smartphone Web Browser.

Assuming that out Views were built for Desktop Browsers we need to create a new theme for Smartphones. We will name the theme "smartphone".

In the plugins directory we create a directory called "Smartphone"

cd plugins
mkdir Smartphone
mkdir Smartphone/src
mkdir Smartphone/src/Template
mkdir Smartphone/src/Template/Layout
touch Smartphone/src/Template/Layout/default.ctp

Copy the content of default.ctp to the new smartphone default.ctp.

Next we need to tell the AppController that it must use the theme "Smartphone" for mobile devices. After the modification the AppController.php should look as follows.

   public function initialize()
        $this->loadComponent('RequestHandler');   // required for isMobile

        if ($this->RequestHandler->isMobile() and strpos(env('REQUEST_URI'),'json') == FALSE ) {
        } else {
Next: Building a RSS feed with CakePHP3 UP: TOC