Welcome Guest, Not a member yet? Register   Sign In
How to Process Params of a Route Callback Function?
#1

Id like to have the following routes:

mydomain.com/controller/specific_method/any_param => remains as is
mydomain.com/controller/specific_param => mydomain.com/controller/index/specific_param
Ive set up the following route:

Code:
$route['controller/(:any)/(:any)'] = function ($a, $b) {
 $r = 'controller/';
 switch($a) {
   case'specific_method':
     $r .= $a.'/'.$b;
   break;
   case'specific_param_for_index':
     $r .= 'index/'.$a.'/'.$b;
   break;
 }
 return $r;
};

The results of navigating to the various links are:

mydomain.com/controller/specific_method/param => the method is loaded but the param is ignored.
mydomain.com/controller/specific_param_for_index => 404 error, file not found. It appears that the 'index/' is not inserted into the url.

Assuming the controller is properly setup with index and specific_method ready to process their params, what might I be doing wrong here?
Reply


Messages In This Thread
How to Process Params of a Route Callback Function? - by grins - 07-06-2016, 08:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB