In CakePHP, there is by default layout in (app/View/Layouts/default.ctp) file, But there are many cases in which we can apply different layout in pages as per our client requirement.
Case- 1 If we dont want any layout for our controller method, then we set the layout property Null.
class UsersController extends AppController {
Var $layout = Null; // For all actions
public function index(){
$this->layout = Null; // For particular action
}
}
Case- 2 If we want to apply multiple layout in our pages, then we set different layout in our action.
function index() {
$this->layout='indexlayout'; //app/views/layouts/indexlayout.ctp
}
function view() {
$this->layout = 'viewlayout'; //app/views/layouts/viewlayout.cpt
}
0 Comment(s)