![]() |
User agent code for entire application - 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: User agent code for entire application (/showthread.php?tid=5152) |
User agent code for entire application - El Forum - 01-08-2008 [eluser]bapobap[/eluser] Hi there, Quick question. I have about 4 lines of code that checks if the user agent is a mobile device or a normal browser. It then sets a variable, which I use to include the files necessary to build the view. My entire application would need to be able to "see" this var but I'm not sure where to put the code so that the var is set when a page is requested then available to all the code throughout my app. Does anyone have a suggestion on where the best place to put this (and similar code) is? Sorry if I'm not making sense! Thanks! User agent code for entire application - El Forum - 01-08-2008 [eluser]tonanbarbarian[/eluser] if you set the value you want in the config object you will be able to access it anywhere Code: $this->config->set_item('my_value', $value); Code: $this->config->item('my_value'); User agent code for entire application - El Forum - 01-08-2008 [eluser]bapobap[/eluser] Thanks for that, should I put that line in a certain file, or does it not matter where I put it? Thanks User agent code for entire application - El Forum - 01-08-2008 [eluser]tonanbarbarian[/eluser] It does matter to a certain degree where you put it in a controller or model Code: $this->config->set_item('my_item', $value); Code: $CI =& get_instance(); User agent code for entire application - El Forum - 01-08-2008 [eluser]bapobap[/eluser] Thanks for your help! |