Welcome Guest, Not a member yet? Register   Sign In
route question
#1

[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.)
#2

[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';




Theme © iAndrew 2016 - Forum software by © MyBB