• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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