Comments: Layouts

By dmadruga on 16/4/08

1 - Small correction

3th paragraph: Instead of "you need to tell CakePHP where to place __your the code__ for your views." write "you need to tell CakePHP where to place __the code__ for your views.

By dmadruga on 16/4/08

2 - Oopss

Sorry! Didn't see the edit option.

By phpcurious 5 days, 4 hours ago

3 - Multiple Layouts on CakePHP

I don't know if this is really application specific. I would still think to get some pointers or advice from the cakebook on how to implement multiple layouts.

I know you can change the layout by changing value of $this->layout in controller, but you cannot afford to repeat assigning the layout filename to $this->layout everytime you need to change your layout.

An example of quick implementation of multiple layouts I could think of is in the app_controller.php file:

class AppController extends Controller {

var $custom_layouts = array('Pages'=>'default','Articles'=>'article','Dashboard'=>'dashboard');

function beforeRender() {

if(array_key_exists($this->name,$this->custom_layouts))

$this->layout = $this->custom_layouts[$this->name];

}

}