Reputation: 304
How to set different layouts for all controllers and actions in Yii app, for different user roles. For example, if user is a client, set the layout1, else if company - layout2. In what place should I place this logic. Thanks!
Upvotes: 1
Views: 190
Reputation: 11839
Imho, custom filter is a best option
http://www.yiiframework.com/doc/guide/1.1/ru/basics.controller#sec-5
Upvotes: 0
Reputation: 437854
The controller's beforeAction
method is a good place to do this -- you can apply the logic to one controller only or all of them (inside the base controller class) and the action itself can choose to override the preselected layout if needed.
Upvotes: 1