在 Yii 框架中 $this->redirect
函数不工作。
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');
}
}
最佳答案
尝试:
$this->redirect("site/index");
或者如果你想重定向到主页:
$this->redirect(Yii::app()->homeUrl);
从 CWidget 尝试:
$this->owner->redirect(array("site/index"));
阅读更多 here关于从小部件重定向。
关于php - yii 重定向不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25883567/