Module conflict with CGridView and UrlManager

You can try to reproduce this bug by setting on your UrlManager in, config/main.php and then trying pagination or sorting in your CGridView. The ajax urls are not correctly generated, like sorting.

There are people that has got involved with this bug:

http://www.yiiframework.com/forum/index.php?/topic/18964-cgridview-urlmanager-module-conflict/page__gopid__135524#entry135524

http://www.yiiframework.com/forum/index.php?/topic/16790-gridview-clinkpager-and-urlformat-path/

And myself I found the solution to fix the bug by changing createUrl function. I know it’s not right place where to fix it and this is not dynamic code, but I needed quick solution.

This is how I change it in framework/base/CApplication.php




	public function createUrl($route,$params=array(),$ampersand='&')

	{

		

		//THIS HACK IS MADE BY paulusmikkola@hotmail.com. Yii seems to have module conflict with CGridview and UrlManager

		$newParams = array();

		foreach($params as $key => $p)

		{

			//insert your own controller + /admin instead of "person/admin" and "invoice/admin"

			if(substr($key, 0, 12) != "person/admin" && substr($key, 0, 13) != "invoice/admin")

			{

				$newParams[$key] = $p;

			}		

		}

		$params = $newParams;

		//END OF HACK

		

		return $this->getUrlManager()->createUrl($route,$params,$ampersand);

	}



I hope Yii crew could write a little peace of code to get this problem solved dynamically without complicating UrlManager parameter inserting. The problem is that for some reason $params array’s first parameter is repeating almost the whole url.