Welcome Guest, Not a member yet? Register   Sign In
Beginner needs help with routing
#1

[eluser]canado[/eluser]
Hi there

I m new to the codeigniter, so far I really love it.

I still have a little issue with routing. Until now I was hardcoding my routings such as

$route['en/products/textile/towels'] ="products";

Now I m about to create the product detail view and I wanted to have something clean with the use of regex

so I still want to have this
$route['en/products/towels'] ="products";
$route['en/products/textile/towels'] ="products";
but also have this
$route['en/products/textile/01010101'] ="item";
$route['en/products/textile/towels/01010101'] ="item";

01010101 = the code of the article.
and I want the regex to be smart enough to allow one two or more blocks after products/block1/block2/block3

so I need to find a way to detect if my uri contains a digit at the end, if yes the controller will be item, if not the controller will be products

I managed (somehow) to find the regex for the uri without number at the end
(en|fr)/(products|produits)/([\D]+)?(^\D) it works here http://gskinner.com/RegExr/

but when I applied the "products" controller, it doesn't work well

Can someone help me to demystify all this, thanks in advance





Theme © iAndrew 2016 - Forum software by © MyBB