Yii Framework Forum: Redirecting to a specific Page - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Redirecting to a specific Page

#1 User is offline   Sler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 17-July 12

Posted 06 August 2012 - 03:36 AM

Hello,

I would like to rephrase my problem.

I have an admin.php in protected folder...
It just shows a different output in the homepage.

My goal is, after I login, I would like to redirect it to admin.php..

I think that I would change this code(BOLDed and colored red) in site/login:

public function actionLogin()
{
$model=new LoginForm;

// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}

// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->homeUrl);
}
// display the login form
$this->render('login',array('model'=>$model));

}

What do I change their, in order for it to redirect to admin.php?

Chabx
0

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 498
  • Joined: 21-May 11
  • Location:India

Posted 06 August 2012 - 06:23 AM

$this->redirect(array('controllerName/actionName'));  // you must have specified controller to rander admin page
or
$this->redirect(array('folderWhereAdmin.phpFile/admin'));

Thanks,
Kiran Sharma.
0

#3 User is offline   alirz23 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,247
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 10 August 2012 - 03:26 AM

you can use


$this->redirect(array("controller/admin"));

this should do it
0

#4 User is offline   Sler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 17-July 12

Posted 10 August 2012 - 11:31 AM

Greetings Shiran and Alirz

Yup. Thnx to both of you... :) That was the code I was looking for. :)

Chabx
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users