hi
to show my url "item/admin/1 " instead of "item/admin?category_id=1", i added below rule, but nothing change
what wrong with me?
'<controller:\w+>/<action:\w+>/<category_id:\d+>'=>'<controller>/<action>',
hi
to show my url "item/admin/1 " instead of "item/admin?category_id=1", i added below rule, but nothing change
what wrong with me?
'<controller:\w+>/<action:\w+>/<category_id:\d+>'=>'<controller>/<action>',
Can you show the rest of your rules? You might find that an earlier rule is matching before this one is reached.
thanks for reply
here is my rules:
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<category_id:\d+>'=>'<controller>/<action>',
i only added the last one like the second rule
Your third rule is matching first. Change the rules to this order:
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<category_id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
thanks, it works now
would you plz describe it a bit more, how the third rule matched first? in that rule i didnt have category_id, so it matched with what?
This:
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
is a more general rule and will be matched if your path contains two segments that follow the specified format. The rest of the parameters will be passed in the query string.
Once a rule has matched, no more rules are evaluated, so if you want to use a more specific URL rule, you have to put it earlier in the list.
after these changes i faced with a new problem
below if always return false
<?php if(isset($_GET['category_id'])):?>
<?php $this->renderPartial('/item/_form',array('model'=>$item,));?>
<?php endif; ?>
what’s the solution?
thanks
Is there anything in the GET array? What does the following code produce?
var_dump($_GET);
ohh, it returned id instead of category_id
why?
how can i change it to category_id?
I probably should have spotted this earlier. The URL manager can’t distinguish between these two rules for incoming requests:
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<category_id:\d+>'=>'<controller>/<action>',
You might need to put a specific controller and/or action for the category rule and move it up in the rules.
'item/admin/<category_id:\d+>'=>'item/admin',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',