I use generated actions by Gii in a module said News. I have normal view action that works with an id parameter (such as example.com/news/view/id/1
).
When I use this line of code:
Yii::app()->createUrl("news/view",array("id"=>$data->primaryKey))
It generates example.com/news/1
(if $data->primaryKey
is 1). It is not correct.
When I use this line of code:
Yii::app()->createUrl("news/view/id/",array("id"=>$data->primaryKey))
It generates example.com/news/id/id/1
(if $data->primaryKey
is 1).
I am so confused! in first situation, this function doesn't generate id as a parameter name, and in second situation, it does! but after manually added id.
What shoud I do to make correct url format with this function?
Edit: news is a module. I changed the line of code as:
Yii::app()->createUrl("news/default/view/id/",array("id"=>$data->primaryKey))
It generates example.com/news/default/view/id/1
that is correct, but I don't want that default!