I’m implementing a password protected website. I have defined 2 different layouts in views/layout for guest and members. Basically header and footer are displayed for members and none for guest. I managed to get it work by defining function init() in controller classes:
public function init() {
$this->layout = Yii::app()->user->isGuest ? 'guest' : 'member';
}
It seems repetitive to duplicate this code in all controller classes. Is there a simpler way to define this only once and apply to all controllers?