Remap function for CodeIgniter
July 26th, 2009 Posted in Bin
I got tired of looking for this code in other projects so I wanted a handy place to keep it.
PHP:
-
<?php
-
function _remap($method)
-
{
-
$this->$method($this->uri->segment(3));
-
} else {
-
$this->index($method);
-
}
-
}
-
?>
In case you're wondering, this function is a reserved method in CodeIgniter controllers that will allow for a dynamic method name to be passed into the URL. Docs on it are here: codeigniter.com/user_guide/general/controllers.html#remapping.
August 5th, 2010 at 10:59 pm
Thanks man, this remap method save my life!
really thanks!
September 16th, 2010 at 1:21 pm
Thanks, I was just looking for this. About to write it myself, and did one last google search, and boom.. you wrote it for me. Works like a champ.
I will mention, in my case, I had to catch real 404′s in the function in the else statement and call show_404() if the input isn’t valid. (I’m using this to call a search if there’s no controller function for the exact URL).
Appreciate it, keep up the good work.