Urlmanager

Hi,

I want to deal with the dynamic action on the fly using one static action browse, I encounter an

unable to resolve the request "item/xxx-yyy-zzz" error.

I found this (http://www.yiiframework.com/forum/index.php/topic/33344-create-dynamic-action-in-controller-file/) is similar to what i want to do.

I have set the urlManager as below.

	'urlManager'=>array(


		'caseSensitive' => false,


		'urlFormat'=>'path',


		'rules'=>array(


			'item/<href:[^ ]*]+>'=>'items/browse',


			'<controller:\w+>/<id:\d+>'=>'<controller>/view',


			'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',


			'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',


		),


	),

and here is my controller.

public function accessRules()


{


	return array(


		array('allow',  // allow all users to perform 'index' and 'view' actions


			'actions'=>array('index', 'browse', 'list'),


			'users'=>array('*'),


		),


		array('allow', // allow authenticated user to perform 'create' and 'update' actions


			'actions'=>array(''),


			'users'=>array('@'),


		),


		array('allow', // allow admin user to perform 'admin' and 'delete' actions


			'actions'=>array('admin','delete', 'create','update'),


			'users'=>array('admin'),


		),


		array('deny',  // deny all users


			'users'=>array('*'),


		),


	);


}

public function actionBrowse($href)


{


	$this->render('view',array(


		'model'=>$this->loadModelByHref($href),


	));


}


public function loadModelByHref($href)


{


	$criteria=new CDbCriteria();


	$criteria->condition = 'href=:href';


	$criteria->params = array(':href'=>$href);


	$model = Item::model()->find($criteria);


	if($model===null)


		throw new CHttpException(404,'The requested page does not exist.');


	return $model;


}

Anything I missed or programmed incorrectly?

Please help, thx


'item/<href:[^ ]*]+>'=>'items/browse',

there is additional "]" and "*" that are not quoted in regexp… it should be sth like:


'item/<href:[^ ]+>'=>'items/browse',

or


"item/<href:[^ \\]*]+>"=>'items/browse',

Hi,

thx for your help, it works.

I have tested my regular expression using some testing ‘href’ in the web, but don’t know why it will fail.