• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URI Routing with more than one variable?


Is it possible to set up a routing rule that took e.g.
and passed BOTH the category_id and the product_id to whatever function?

In the User Guide, there's an example for only one variable:
$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";

Thanks in advance for any replies.

I haven't tested it myself, but it works much like regular expressions, so you should be able to use:

$route['product/(:num)/(:num)'] = "products/$1/$2";

If that doesn't work, the normal regex version should:

$route['product/([0-9]+)/([0-9]+)'] = "products/$1/$2";

Just add the rule in your routing config (with regular expressions or whatever) and then you can grab the variables with uri->rsegments().

Thanks for your replies!
I used Lukifer's first option, worked a charm :-)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.