![]() |
Include Variable - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Include Variable (/showthread.php?tid=59649) |
Include Variable - El Forum - 10-31-2013 [eluser]yoelrodguez[/eluser] Hi I have a file with variables that I use throughout the system, as I can include it for use in all controllers Include Variable - El Forum - 10-31-2013 [eluser]Tpojka[/eluser] You need to extend CI_Controller class. Best approach is to make MY_Controller file located in application/core folder that will extends CI_Controller. After that you only need to extend your controllers with MY_Controller NOT WITH CI_Controller. In that file you can store values for approaching later from any file that uses MY_Controller; application/core/MY_Controller.php Code: class MY_Controller extends CI_Controller { application/controllers/blog.php Code: class Blog extends MY_Controller { But also read this page. Include Variable - El Forum - 10-31-2013 [eluser]yoelrodguez[/eluser] thank you! Include Variable - El Forum - 11-01-2013 [eluser]CroNiX[/eluser] There is a config system that you can use for this. http://ellislab.com/codeigniter/user-guide/libraries/config.html Also, if your file is just a bunch of define() statements or something, you can always just include() it in index.php. |