Switching layouts judging of page type

Hello everybody! I’m trying to structure my yii 2.0 app and I’d like to have several layouts and switch them for different types of pages straight in Controller. How could I perform these requirements? How does the application logic look like in this case?

E.g.:

(login layout -> login page, set of login errors)

(main layout -> main pages)

and so forth.




if (your condition) {

    $this->layout = 'xxx'

}