How to change the cakephp layout

0

I created a newsletter submission layout, called email.ctp , and put it inside the View / Layout directory. My question is how do I use this layout instead of the default.ctp     

asked by anonymous 18.12.2014 / 18:34

1 answer

2

You will need to use $this->layout = ...; on your AppController

You can use:

public function beforeRender() {
    parent::beforeRender();

    $this->layout = 'layout_customizado';
}

Another example would be to apply a layout for each "View" within AppController

class UsersController extends AppController {
    public function view_active() {
        $this->set('titulo_para_o_layout', 'Ver atividade dos usuários');
        $this->layout = 'layout1';
    }

    public function view_image() {
        $this->layout = 'layout_image';
        //Mostra foto do usuário
    }
}
    
18.12.2014 / 18:42