deib97
(Deib97)
1
I use multi layout di Component Controller with function like this.
But the result not show layout what i means, still use layout main.
my code :
public function beforeAction($action)
{
if (Yii::app()->user->isGuest && $action->id != 'login') {
$this->layout = '//layouts/login';
$this->redirect(Yii::app()->createUrl('user/login'));
}
Maybe add revision on yii 1.1.16?
h3rm
2
what is your function inside the Controller class ?
i’m not sure why you set ‘layout’ and then make the page redirect into another page.
you should set the layout in the ‘user/login’ action.
deib97
(Deib97)
3
Yes, i use different layout when user before login and after login. And default controller is siteController.
lagogz
(Lagocamanho)
4
Hello.
As Hermans says, why do you set layout and then redirects?
I think you only have to write this code into your login action:
if(Yii::app()->user->isGuest)
{
$this->layout = '//layouts/login';
}
else
{
$this->layout = 'another layout';
}
And on the other actions, you can set another layout and ready (or you can use the default controller layout).
Regards.