Yii urlManager route with query string

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

I need some predefined URLs like /About /Contact or some other special special page like /LatestUpdates or /HTCDesire

I can do "Contact" => "site / contact" for matching / contact / contact / contact / contact

How can I "program a query string" on a route?

I'm trying to:

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

but does not work, 404 was not found because it expects the right side to be the route in the format / action controller.

I'm trying to:

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

I can go to /LatestUpdates , but the link to the binding still shows /update/view/id/65

Is there another way?

+4
source share
1 answer

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

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

Read more about it here and here .

Hooray!

+8
source

Source: https://habr.com/ru/post/1343037/


All Articles