CodeIgniter Forums
route question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: route question (/showthread.php?tid=2073)



route question - El Forum - 07-14-2007

[eluser]Unknown[/eluser]
Is it possible to do this:

Code:
$route['product/:any'] = "catalog/product_lookup";

From the user guide, it says that doing that will have any url that is product/anything will be sent to catalog/product_lookup

I'm wondering how it is possible to get that :any as a variable in the document. Is it done with the uri segment thing? If so, how?

Thanks.

EDIT: Would it be done like this:
Code:
$product_id = $this->uri->segment(2);

then $product_id would equal :any?

(If this is really simple, sorry, I'm new to using CI.)


route question - El Forum - 07-15-2007

[eluser]Glen Swinfield[/eluser]
Yes,

Code:
$route['product/:any'] = "catalog/product_lookup";

will work, then your url will be http://www.theurl.com/product/myproductid

Then:

Code:
$product_id = $this->uri->segment(2);
echo $product_id;

prints 'myproductid';