Using helpers in Routes.php ?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using helpers in Routes.php ?? (/showthread.php?tid=49184) |
Using helpers in Routes.php ?? - El Forum - 02-10-2012 [eluser]umbungo[/eluser] I would like to know how i can use a helper in routes.php. I have a list of main categories in config.php, and a custom url helper. I would like to do the following instead of mainting 2 separate lists; Code: foreach(config_item('categories') as $category){ Using helpers in Routes.php ?? - El Forum - 02-10-2012 [eluser]CroNiX[/eluser] Nope, not natively. You probably could if you extended the router class. Routes get loaded way early on in the bootstrap process as it's needed to determine which controller/method to load and process. Check the /system/core/CodeIgniter.php file to see how most things get loaded and in what order. Using helpers in Routes.php ?? - El Forum - 02-10-2012 [eluser]umbungo[/eluser] Could i just copy the code from the helper into routes.php? could i use it as a function then?/how Using helpers in Routes.php ?? - El Forum - 02-10-2012 [eluser]Aken[/eluser] You could add the function to your index.php, config file or route file and have it work fine. It would then make it globally available just like autoloading a helper file. |