In Yii framework $this->redirect
function not working.
class TplUserNavigation extends CWidget{
public function run()
{
if(isset(Yii::app()->user->id) && Yii::app()->user->getState('userType') == 'User'){
$users = Users::model()->findByAttributes(array('id'=>Yii::app()->user->id));
$this->render('webroot.themes.'.Yii::app()->theme->name.'.views.layouts.tpl_navigation', array('users'=>$users));
}else{
$this->redirect('site/index');
}
}
Try:
$this->redirect("site/index");
or if you want to redirect to home page:
$this->redirect(Yii::app()->homeUrl);
From CWidget try:
$this->owner->redirect(array("site/index"));
Read more here about redirect from widget.
Since you're just trying to go to the site's index, try something like this:
$this->redirect(Yii::app()->baseUrl);
If you want to redirect the user to some other page than the home page try using:
$this->redirect(Yii::app()->createUrl('controlller/action'));
This will come handy when you try url rewriting using yii url rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With