Parameters to Controller index() |
[eluser]insub2[/eluser]
What is the easiest way/most automated way to send data from the URL to the index function of a controller so that other methods still work? I'd prefers something that doesn't require me to list out all of my methods. Also, I'd like to avoid messing with routes.php. The scenario is basically... Code: class Post extends Controller
[eluser]Colin Williams[/eluser]
_remap() baby! I rarely write a controller without one. Code: class Post extends Controller You could make it more robust (like pass all URI params to index()) but that's the gist.
[eluser]insub2[/eluser]
Thanks for your response. That is close but darn _remap doesn't accept more than one argument and also breaks the standard URI segment passing (e.g. function foo($arg1, $arg2) ). What I really want is for URL http://fake-domain.com/controller/one/two/three/etc to check if one is a method. If yes, act completely normally 100% (without having to use $this->uri->segment(n) ). If not, act as if "index/" had been inserted before "one".
[eluser]Colin Williams[/eluser]
Very easy solutions to those problems (that's what I meant by making it more robust). So, voila!: Code: function _remap($method)
[eluser]Colin Williams[/eluser]
No problem. Clear, concise questions and requests here typically get good responses. So, thank you for being a good asker.
[eluser]puzzlebox[/eluser]
wow this is really cool.. I could use this one on my project.. ![]() |
Welcome Guest, Not a member yet? Register Sign In |