Creating config variable file - 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: Creating config variable file (/showthread.php?tid=11062) |
Creating config variable file - El Forum - 08-24-2008 [eluser]bigdaddysheikh[/eluser] Hey guys, I keep running into the problem of "undefined variables". It is driving me bonkers. First I declared them in each class and sub fucntion. This lead to too many same lines in different controllers. I tried making a config file by setting the variable $data and arrays inside $data. That did not help. So for example, I will have an error message or message i want to display, or generic html messages. $data["error"] $data["title"] $data["footer"] How can I set these variables? Which file would they go in and how will this file be accessed so my website will not show any of those udefined errors again. Thank you in advance. Creating config variable file - El Forum - 08-24-2008 [eluser]Colin Williams[/eluser] Did you miss the Loader class documentation in the user guide? It details the many ways to make data available in your View files. Also, there is clear documentation on how to add and use your own config files, but here's the basic rundown. Add the file application/config/my_config.php Code: $config['an_item'] = 'A value'; Then to get at these items, we must first load this config file. One way is with the Loader class: Code: $this->load->config('my_config'); Creating config variable file - El Forum - 04-07-2012 [eluser]bluepicaso[/eluser] thank you |