CHtml::link broken using urlManager for blog module

I have converted the Yii blog demo into a module.


'urlManager'=>array(

			'urlFormat'=>'path',

			'showScriptName'=>false,

			'rules'=>array(


        		'/blog/post/<id:\d+>/<title:.*?>'=>'/content/post/view',

        		'/blog/posts/<tag:.*?>'=>'/content/post/index',

        		'/blog/<controller:\w+>/<action:\w+>'=>'/content/<controller>/<action>',



All of the above rules work, if I type them into the web browser manually.

However, the links generated by:


<?php echo CHtml::link(CHtml::encode($data->title), $data->url); ?>

is not in path format!

eg. /post/4?title=test2

However other things ARE in path format:

/blog/post/create

I’m really confused to what the problem may be.

I found a solution. It looks like there might be a bug in CreateURL.

I had to manually insert the module id into the createUrl function in the post controller. However, it is suppose to do this automatically.

“Since version 1.0.3, if the controller belongs to a module, the module ID will be prefixed to the route. (If you do not want the module ID prefix, the route should start with a slash ‘/’.)”

http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail

This is my temporary fix, inserting the module ID and a /.


	public function getUrl()

	{

		return Yii::app()->createUrl(Yii::app()->controller->module->id.'/'.'post/view', array(

			'id'=>$this->id,

			'title'=>$this->title,

		));

	}