Clean Url Partially Working With Parameters


I am able to have clean URL’s where I am navigating within a controller instance

So I am able to go from say Posts CGRIDVIEW and view a Post. All works good as I get the URL:


However, what I want to do is say have a list of Authors (CGRIDVIEW), click and go to the view for the author and see a list of the posts (CGRIDVIEW) and then click on a specific post and get its view.

Now I am able to generate the URL but it generates:


instead of


Now I have URLManager set correctly but I think there may be a rule I need to generate to get this to work.

Any help appreciated.

You are passing post_id instead of id. :)

You can either change what you’re passing, or change the url rules and/or change the parameter which your post controller view action takes.

Thank you.

Yes that was the problem I had the database field name on both parts of the URL generation.

It should have been:

'viewButtonUrl'=>'Yii::app()->createUrl("/post/view", array("id"=>$data["post_id"]))',

but I had

'viewButtonUrl'=>'Yii::app()->createUrl("/post/view", array("post_id"=>$data["post_id"]))',

Note that at the start of the array I had the database field "post_id" instead of the passing parameter of "id".