techie_28 techie_28 - 5 months ago 28
PHP Question

Assigning Layout in cakephp

Can we define a Layout for whole controller in that particular controller?I have used before filter of the appcontroller for this purpose earlier but it doesnt solves it any more.So i need that there should be some definition of layout in controller that would apply for all the actions of that controller.

Regards

Answer

use it:

inside your action

$this->layout = 'mylayout';

you have to create that layout in view/layout/mylayout.ctp

or add this function to controller to set layout for each action of controller

  function beforeFilter() {
    parent::beforeFilter();
        $this->layout = 'mylayout';
  }