I would like to set up my Yii webapp so that the url
/username will show the user record for that user.
I've tried
'<username>'=> 'user/view'
, but this results in an error 400.
'<id:\d+>'=> 'user/view'
works.
I would like to set up my Yii webapp so that the url
/username will show the user record for that user.
I've tried
'<username>'=> 'user/view'
, but this results in an error 400.
'<id:\d+>'=> 'user/view'
works.
I've managed to work out what I was doing wrong.
The variables that you put in your url routes need to correspond to the functions in your controller actions.
So I changed the standard actionView generated by gii to
public function actionView($username) {
$model=User::model()->find("username = '".$username."'");
$this->render('view',array('model'=>$model);
}
Now . . . '<username>'=> 'user/view'
as a url route works as expected .