Valentin Melnikov
Valentin Melnikov

Reputation: 304

Yii layout managing for different user roles

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

Answers (2)

cetver
cetver

Reputation: 11839

Imho, custom filter is a best option
http://www.yiiframework.com/doc/guide/1.1/ru/basics.controller#sec-5

Upvotes: 0

Jon
Jon

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

Related Questions