Routes: how to get mycontroller/id function same as mycontroller/action/id |
[eluser]easymind[/eluser]
http://xxx.xx/cars/1 runs the function called 1 inside your controller cars (so it will not start the index function and pass 1 as a argument) http://xxx.xx/cars/index/1 runs the index function inside your controller cars and passes 1 as the first argument As suggested to you, this can be done nicer by making a function called show, so you can leave out index in the url and replace it with show. Show will have to do what you want index to do. So you will get the url: http://xxx.xx/cars/show/1 The other suggestion was routing. So cars/1 goes to cars/index/1 or cars/show/1, whatever you like... Is this a simpler explanation of the suggested solutions above? |
Welcome Guest, Not a member yet? Register Sign In |