CUrlManager splitted to 2 classes

Hi,

When we try to extract an ID from an url-friendly ID (example: /post/32-do-you-like-bananas) we will use :


'rules' => array(

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

CUrlManager will extract ‘32’ as $id in :


public function actionPost($id) {

echo $id; // outputs 32

}

but in the same time, it will also create urls like :

localhost/post/32-do-you-like-bananas\-.+

That’s why i think Yii should enable 2 separated rules arrays.

One will be used for createUrl() and another one for parseUrl()

oops,

it was my rules syntax

i solved the problem

Would be nice if you can write here the rigth rule syntax… this would help if someone in the future comes to this thread with a similar problem.

Here is a portion of code that worked fine with the default URL manager:




        'urlManager'=>array(

            'urlFormat'=>'path',

            'showScriptName'=>false,

            'rules'=>array(

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

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

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

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

            ),

        ),



Assuming you are creating URLs like :




$this->createUrl('products/details',array('id'=>$data->id,'title'=>$data->title));