Welcome Guest, Not a member yet? Register   Sign In
arguments to a controller instead of function
#2

[eluser]mddd[/eluser]
If you ALWAYS want to go to the index method you can use this route:
Code:
$route['user/(.*)'] = 'user/index/$1';

This makes /user/john go to user/index/john. And you're done.

If you want to rewrite but also want to keep the possibility of other methods in the controller,
you can use the _remap method. If there is a _remap method in the controller, it is always executed!

Check the manual page about routes for more info.

Code:
function _remap($requested_method)
{
   // check if a function was requested that we know what to do with
   if ($requested_method=='list')
      // show a list of users

   else
      // the requested method isn't anything we know about, so treat it as a username that we show through the index method
      $this->index($requested_method);
}


Messages In This Thread
arguments to a controller instead of function - by El Forum - 07-07-2010, 05:07 AM
arguments to a controller instead of function - by El Forum - 07-07-2010, 05:24 AM
arguments to a controller instead of function - by El Forum - 07-07-2010, 06:09 AM
arguments to a controller instead of function - by El Forum - 07-07-2010, 06:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB