i’m developing a new site and i have this situation:
- Products
\_ Category1
\_Product1
\_Product2
\_ Category2
\_Produc1
\_Product2
I have created my Product controller to show all the category but now i need to create a controller for each category, is it possibile?
I would have something like:
http://www.example.com/product/category/product-name
how can i setup my controller? i can’t write a method for each category because this is not definited…
You should use the Product Controller, add a function load_category($category_name=”) and route URL segment to this function.
Edit app/config/routes.php and add a line like this:
An so any URL like:
http://www.example.com/product/categorya or
http://www.example.com/product/categoryb or ..
will send a request to load_category methos from Product Controller.
Add this for products: