![]() |
Parameters to Controller index() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Parameters to Controller index() (/showthread.php?tid=24593) |
Parameters to Controller index() - El Forum - 11-13-2009 [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 Parameters to Controller index() - El Forum - 11-13-2009 [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. Parameters to Controller index() - El Forum - 11-16-2009 [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". Parameters to Controller index() - El Forum - 11-16-2009 [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) Parameters to Controller index() - El Forum - 11-16-2009 [eluser]insub2[/eluser] OMG Thanks! You are the coolest! Parameters to Controller index() - El Forum - 11-16-2009 [eluser]Colin Williams[/eluser] No problem. Clear, concise questions and requests here typically get good responses. So, thank you for being a good asker. Parameters to Controller index() - El Forum - 11-17-2009 [eluser]Unknown[/eluser] Thanks. Parameters to Controller index() - El Forum - 11-17-2009 [eluser]puzzlebox[/eluser] wow this is really cool.. I could use this one on my project.. ![]() |