Hi all,
I wanted to make login page as homePage and hide menu section if not logged in.
I did the following:
main.php (layout)
<?php if(!Yii::app()->user->isGuest): ?>
<div id="mainMbmenu">
...menu...
</div><!-- mainmenu -->
<?php endif;?>
In SiteController.php
public function actionIndex()
{
if(!Yii::app()->user->isGuest){
$this->render('index');
}
else
$this->redirect(array('site/login'));
}
public function actionLogin()
{
$model=new LoginForm;
....
if($model->validate() && $model->login())
$this->redirect(array('site/index'));
....
}
This works fine (as I wanted) but my question is:
Is this the correct way to do it?
Thanks