In YII If there is blank space in title which is being used for url, then by default blank spaces are replaced by "+" sign. Something like this:
www.domain.com/event/view/id/Dj+Robag+Ruhme
What I want to do is, I want to replace "+" sign by "-" (dash sign) or by "_" (underscore). Something like this:
www.domain.com/event/view/id/Dj-Robag-Ruhme
or
www.domain.com/event/view/id/Dj_Robag_Ruhme
Right now my urlManager is:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
//'<controller:\w+>/<id:\d+>'=>'<controller>/view',
//'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
//'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
Well, nothing strange since Yii use
urlencode
to encode url parameters.First approach
You could handle this in your model, e.g. :
Don't forget to :
model
with the name of your model,modify your view action in your controller :
Second approach
You could use your own
CUrlRule
class :http://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-custom-url-rule-classes