Routes: how to get mycontroller/id function same as mycontroller/action/id |
[eluser]marcoss[/eluser]
[quote author="dreamynsx" date="1192840619"]Well the real idea for all this is that my index action will show a list of cars, and can accept a category Lets say I have 20 categories. I wouldn't want to create 20 different methods just to support this. So back to the function index($cat="") { ... } www.site.com/cars/index/sports <-- works (shows 'sport' cars) www.site.com/cars <-- works (just show default list) www.site.com/cars/sports <-- fails ...[/quote] Again, you are missing the point here, it is about architecture, you should do something like this Code: class MyController extends Controller Now you have, http://site.com/cars/show/sports --> will list all cars on sports category. http://site.com/cars/show/sports/5 --> will get the car with id 5 in the sports category. |
Welcome Guest, Not a member yet? Register Sign In |