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
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';
}
The best way to do some thing like this
var $layout = 'my_account';
This will apply to your entire controller. After adding this code it will look something like this.
class MyAccountsController extends AppController {
var $name = 'MyAccounts';
var $components = array('Email');
var $layout = 'my_account';
If you do not want to use some of the action you can explicitly define in your action like this
function my_action(){
$this->layout = 'another_layout';
}
Now this my_action
will take another layout and rest of the action will take my_account
layout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With