I read guide to url manager. I have question is it possible to create rule for example:
'about_us' => 'site/pages' and add constant id to GET parameters for example
example.com/about_us would be equal to example.com/index.php?r=site/pages&id=4
Page 1 of 1
Question about urlManager
#2
Posted 16 February 2010 - 07:50 AM
Everything's possible with Yii 
'about_us' => array('site/pages', 'defaultParams' => array('id' => 4)),
#3
Posted 16 February 2010 - 07:57 AM
andy_s, on 16 February 2010 - 07:50 AM, said:
Everything's possible with Yii 
'about_us' => array('site/pages', 'defaultParams' => array('id' => 4)),
o thx
but i have another problem with it, is it possible to do something like this
'about_us' => array('site/pages', 'defaultParams' => array('id' => 4)),
'our_partners' => array('site/pages', 'defaultParams' => array('id' => 5)),
because when i do something like that all URLs look like this
about_us?id=3,about_us?id=4
#4
Posted 16 February 2010 - 08:10 AM
Try this property:
http://www.yiiframew...tchValue-detail
But in this situation I recommend you to create different actions "AboutUs", "OurPartners" etc.
http://www.yiiframew...tchValue-detail
But in this situation I recommend you to create different actions "AboutUs", "OurPartners" etc.
#5
Posted 16 February 2010 - 08:29 AM
Predicting your question about what to do, if you have many actions like AboutUs and OurPartners (too much rules and methods to write), I want to suggest a technique:
In UrlManager make a rule:
Then in SiteController define a method missingAction:
In UrlManager make a rule:
'<_a:(about_us|our_partners)>'=>'site/<_a>', // or even a rule like this: '<_a:([A-Za-z0-9_]+)>'=>'site/<_a>',
Then in SiteController define a method missingAction:
public function missingAction($actionId)
{
switch ($actionId)
{
case 'about_us': ...
case 'our_partners': ...
...
default: // you can redirect or throw an exception there or call parent::missingAction($actionId).
}
}
#6
Posted 17 February 2010 - 05:15 AM
Thx for help that is good idea
. I didn't know missingAction function.
Share this topic:
Page 1 of 1

Help












