Just give you an idea of how you can do this.
In app_controller, try running the code below.
<?php class AppController extends Controller { var $components = array( 'Auth','Session', 'RequestHandler','Email','Gzip.Gzip','SwiftMailer'); var $helpers = array( 'Javascript', 'Form', 'Html', 'Session','Time','Custom','Paginator','Text' ); function beforeFilter() { if(isset($this->params['admin']) && $this->params['admin'] == 1) { $this->layout = "admin"; } else { $this->layout = "default"; } } ?>
And inside another controller file that extends the app_controller application, you must have the code as shown below.
<?php class OtherController extends Controller { var public $uses = array('ModelName'); function beforeFilter() { parent::beforeFilter(); } ?>
You can also overwrite $this->layout for each controller action.
source share