B
B
Boris Yakushev2017-05-16 17:09:42
Yii
Boris Yakushev, 2017-05-16 17:09:42

Default template and path depending on site login?

Good afternoon.
Please tell me how to do the following:
There are two controllers and a template:

  • site
  • pa

It is necessary that if the user is authorized on the site the controller and the default template were pa
If the user is a guest, then the controller and the default template site
Thank you all for the advice.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-05-16
@webinar

Well, the template is not a problem:
in the controller

if(Yii::$app->user->isGuest){
$this->template = 'guest';
}else{
$this->template = 'neguest';
}

But why with a controller? Explain, it looks like you started a fundamentally wrong thing.

M
Maxim Fedorov, 2017-05-17
@qonand

Write a behavior that will hook onto the EVENT_BEFORE_REQUEST application event and, depending on the user's authorization status, change the defaultRoute and layout settings of the application

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question