Routes using param to chose which Controllers to use. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Routes using param to chose which Controllers to use. (/showthread.php?tid=84600) |
Routes using param to chose which Controllers to use. - Jag81 - 10-25-2022 Hello, I have the same method name for a group of controllers: PHP Code: public function get_html(){ Intead of writing the complete route for every controller, is there a way to use params in routes to call different Controllers with the same method? Something like this: PHP Code: $routes->get('(:any)/get_html', '$1::get_html'); RE: Routes using param to chose which Controllers to use. - kenjis - 10-25-2022 A dynamic controller is not allowed for security reasons. So you need to extend Router. See https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html |