Search code examples
phpcakephpcakephp-2.0

CakePHP layout not changing


I am working in CakePHP 2.3.0, I developed app using default layout. Now I need to change the layout to design.ctp but the app is rendering default.ctp

    public function myfun() {
      $this -> layout = 'design';

    }

I tried to clear the cache and switched ON the debug mode but the app is still picking the default.ctp


Solution

  • In your controller

    class MyTestController extends AppController {
        var $layout = 'default'; 
    

    and in your action try

    public function myfun() {
      $this->layout = 'design';
    }
    

    Now, your view will use design.ctp, which is stored in views/layouts/.