Welcome Guest, Not a member yet? Register   Sign In
Routing categories, subcategories, subsubcategories and products
#1

[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';
to show my subcategories but then this collides with category/product also which I'd like to redirect to
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';
for my category and
Code:
$route['product/(:any)'] = 'product/index/$1';
for any product, but here I would lose my friendly url and instead of category/product, I'll have product/some-id-or-permalink. I want the full path. Any ideas how to do that? Or I'm open to something different ofcourse.

Thanks in advance.
#2

[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










Theme © iAndrew 2016 - Forum software by © MyBB