Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii urlManager route with query string

This is about setting WebRoot/protected/config/main.php *urlManager* on Yii Framework.

I want a few predefined url like /About /Contact or some other custom special page like /LatestUpdates or /HTCDesire

I can do 'Contact'=>'site/contact' to map /Contact to /site/contact

How can I 'hard code' query string to the route?

I try:

'About'=>'site/page?view=about'
'LatestUpdates'=>'update/view?id=65'
'HTCDesire'=>'product/view?id=33'

but not working, 404 not found because it expect the right side should be route in format controller/action.

I try:

'LatestUpdates'=>'update/view/id/65'

I can browse to /LatestUpdates but the anchor link still shows /update/view/id/65

Is there any other way?

like image 393
CallMeLaNN Avatar asked Mar 09 '11 17:03

CallMeLaNN


1 Answers

This works for me (except I substituted your values in, so maybe I broke it...):

'LatestUpdates'=>array('update/view','defaultParams'=>array('id'=>'65')),

More about this here and here.

Cheers!

like image 93
thaddeusmt Avatar answered Oct 13 '22 05:10

thaddeusmt