CakePHP : How To Not Include Layout In A View

Hello Friends, A layout contains presentation code that wraps around a view. Anything you want to see in all of your views should be placed in a layout.So your every view is wrapped by one layout,If you are not using including layout by $this->layout = ‘layout_name’; than every time it will use default layout, yesterday when I was working on Ajax ,I got one problem in which I don’t want to use any layout in view but it was including default layout, So I have searched on internet about this and hardly find this solution, So I thought to share it on my site.

If you want to use any other layout in view than you have to write in controller like this :

$this->layout = 'layout_name';

‘layout_name’ should be your layout name and which exists in ‘/app/views/layouts’ directory, Now if you dont want to include any layout in view than you have to make false layout for that controller. Like this.

$this->layout = false;

Subscribe to PHP Freelancer

Enter your email address: