How to change the cakephp layout

Asked

Viewed 834 times

0

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

1 answer

2


You will need to use $this->layout = ...; in his AppController

You can use:

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

    $this->layout = 'layout_customizado';
}

Another example would be, applying a layout for each "View" within the 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
    }
}
  • In my case, I used the second example

  • @Mathdesigner47 if it worked, please mark the answer as correct

Browser other questions tagged

You are not signed in. Login or sign up in order to post.