Yii Framework Forum: Clean Url Partially Working With Parameters - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Clean Url Partially Working With Parameters Rate Topic: -----

#1 User is offline   AussieNeil 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-January 13

Posted 08 March 2013 - 08:24 AM

Hi,

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:

http://localhost/demo/index.php/post/view/1


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:


http://localhost/demo/index.php/post/view?post_id=1


instead of

http://localhost/demo/index.php/post/view/1


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.
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 08 March 2013 - 08:32 AM

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.
"Less noise - more signal"
0

#3 User is offline   AussieNeil 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-January 13

Posted 08 March 2013 - 05:26 PM

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".
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users