Hi there!
I recently added the following rule to the URL manager:
'<controller:\w+>/<id:\d+>/<action:\w+>'=>'<controller>/<action>'
This means if I have an url like this:
index.php/user/10/reviews
then it will be parsed as the route: ‘user/reviews’ with GET parameter ‘id’ being ‘10’. That works.
Now I added a CGridView to my page and the navigation links are broken:
'pagination' => array(
'pageSize' => 10,
'route' => 'user/'.$id.'/AjaxDetails',
),
The urls of the navigation buttons are: index.php/user/10/AjaxDetails/page/2 and it should be: index.php/user/10/AjaxDetails?page=2
I managed to debug all the way down and I found why the parameters added with ‘/’:
CUrlManager.php -> createUrlDefault($route,$params,$ampersand)
...
if($this->appendParams)
{
$url=rtrim($url.'/'.$this->createPathInfo($params,'/','/'),'/');
return $route==='' ? $url : $url.$this->urlSuffix;
}
...
Here $this->appendParams is TRUE and it should be false. Docs: http://www.yiiframework.com/doc/api/1.1/CUrlManager#appendParams-detail
I can’t figure out how to make this work. Any suggestion would be appreciated!
UPDATE:
This one would be okay but not in the desired url format:
'pagination' => array(
'pagesize' => 10,
'route' => 'user/AjaxDetails',
'params' => array(
'userId' => '10'
)
),
would generate:
index.php/user/AjaxDetails?userId=10&page=2
The desired URL format is:
index.php/user/10/AjaxDetails?page=2