Welcome Guest, Not a member yet? Register   Sign In
Controller with index($id) method with parameter
#1

Is it possible to have a Controller with the index() method that accepts a parameter?
e.g. controller called "Listjob" with method index($jobid) in such a way to allow this URL to work

http://myapp.local/listjob/53

I have no custom routes set in app/Config/Routes.php and router setup is default

PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true); 

The only way to make it work has been to abandon index($jobid) and just change its name from index to a different one , I used "show"
but now as you may guess I have to browse to

http://myapp.local/listjob/show/53

I also have tried to add a custom route

PHP Code:
$routes->add('listjob/(:any)''listjob/index/$1'); 

but again no success

Thank you for nay hint regarding this
Reply


Messages In This Thread
Controller with index($id) method with parameter - by Corsari - 08-25-2021, 05:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB