![]() |
how get route name from current url? - 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: how get route name from current url? (/showthread.php?tid=88747) |
how get route name from current url? - asnanmtakim - 10-30-2023 how get route name from current url? RE: how get route name from current url? - ozornick - 10-30-2023 Try \CodeIgniter\Config\Services::router()->getMatchedRouteOptions()['as'] ? RE: how get route name from current url? - asnanmtakim - 10-30-2023 (10-30-2023, 02:31 AM)ozornick Wrote: Try \CodeIgniter\Config\Services::router()->getMatchedRouteOptions()['as'] ?Thank you very much for you help RE: how get route name from current url? - kenjis - 11-06-2023 The method is not documented. https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html It may be changed in the future. So I recommend you create a function or method to call above code. Then, even if the method is changed, you will need to update only the function/method code. RE: how get route name from current url? - Sigg - 02-03-2025 Apparently in version CI 4.6.0 this was really changed. Please help me, how can I do this in the current version? Thank you RE: how get route name from current url? - ozornick - 02-04-2025 All works. PHP Code: // Route $routes->get('/', 'Home::index', ['as' => 'homepage']); RE: how get route name from current url? - Sigg - 02-04-2025 Thank you for help! |