Hello guys,
In Url management tutorial having a special topic, that describe how to use UrmManage.
I’d tried it within CHtml::link, but it seem not work!
In my code, I were created a CGridview and in girdview, I have a column that content a CHtml::link like this (Id is following format: ‘xx xx’, so I use str_replace to format it to xxxx):
array(
'header' => 'ID',
'type' => 'raw',
'name' => 'id',
'value' => 'CHtml::link($data->id, Yii::app()->createUrl("lichchay/viewbienso", array("id"=>str_replace(" ", "", $data->id),"month"=>date("m"),"year"=>date("Y"))), array("style" => "text-decoration: none"))',
),
In browser, it displays in status bar like this:
http://host_name/Quanlytour/viewbienso?id=2309&month=01&year=2011
It is not user-friendly url , why don’t it following my url format that was config before in config/main.php?
And in config/main.php:
'urlManager'=>array(
'showScriptName' => false,
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<_c:(lichchay)>/<_a:(viewbienso)>/<id:\d>/<month:\w>/<year:\w>' => '<_c>/<_a>',
),
),
In UrlManager, I added the last one.
Cheers