Routing categories, subcategories, subsubcategories and products - 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: Routing categories, subcategories, subsubcategories and products (/showthread.php?tid=52857) |
Routing categories, subcategories, subsubcategories and products - El Forum - 06-29-2012 [eluser]0v3rth3d4wn[/eluser] Hello! The site I'm currently making has products which are divided in categories, subcategories and subsub categories. I can have products in all of them. I'm giving an example for each possible page I have: shoes shoes/my-product shoes/leather-shoes shoes/leather-shoes/myproduct shoes/leather-shoes/real-leather-shoes shoes/leather-shoes/real-leather-shoes/myproduct I have trouble routing these because sometimes my second and third parameter could be either a subcategory, subsubcategory or a product. I don't want to use controller name or function name. I could do something like this: Code: $route['(:any)/(:any)'] = 'category/index/$1/$2'; Code: $route['(:any)/(:any)'] = 'product/index/$2'; The only thing that comes to my mind is to use it like that Code: $route['category/(:any)'] = 'category/index/$1'; Code: $route['product/(:any)'] = 'product/index/$1'; Thanks in advance. Routing categories, subcategories, subsubcategories and products - El Forum - 06-29-2012 [eluser]cartalot[/eluser] have all categories be at the top level, no matter what type of category /shoes goes to shoes category /leather-shoes goes to leather shoes sub category show the clickable category tree in your breadcrumbs (not the url) Shoes / Leather Shoes / Premium Line / Super Swanky Shoes note: if you have a controller called 'product' or 'shop' you dont need a route just do a product search in the index() function /product/super_swanky |