Help Remaping to Index function |
[eluser]benners[/eluser]
I currently have to include the index in the URL to pass the parameter to the index function. http://localhost/gallery/index/74 I've tried the follow with http://localhost/gallery/74 and it seems to be ok for the Index function but it doesn't remap to other functions in the Gallery Controller. Code: public function _remap($method, $params = array())
[eluser]InsiteFX[/eluser]
Code: public function _remap($method, $params = array())
[eluser]benners[/eluser]
Could you clarify this code please? I've commented a line below and it works for all methods except if index has a parameter. E.g. http://localhost/gallery/74. (I don't understand the purpose of 'process_') Code: public function _remap($method, $params = array())
[eluser]gRoberts[/eluser]
This is where "routes" come into play. Within your routes.php file, you can do Code: $route['gallery/(:num)'] = 'gallery/index/$1'; That way, both 'localhost/gallery' and 'localhost/gallery/74' will work.
[eluser]benners[/eluser]
I've changed my routes for Gallery to: Code: $route['gallery/(:num)'] = 'gallery/index/$1'; And I've removed the _remap code and it works fine. It's looks like the remap code is nolonger needed.
[eluser]gRoberts[/eluser]
I'm not sure why you'd use the third line, since gallery is already mapped. If you had an action called "view" within your gallery file, 'localhost/gallery/view/1' would work fine without your 'gallery/(:any)' route.
[eluser]Aken[/eluser]
Your routes should be in order from most to least specific. Put your (:any) rule above the gallery by itself rule. |
Welcome Guest, Not a member yet? Register Sign In |