Config Item Not Working On Hooks - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Config Item Not Working On Hooks (/showthread.php?tid=64273) |
Config Item Not Working On Hooks - wolfgang1983 - 02-02-2016 Hello I am not sure what I have done wrong with my Hooks On any other controller if I use $this->config->item('maintenance') or config_item('maintenance') It returns the correct value 1 if maintenance mode on or 0 for off. How ever when I try to load it into my hook with $this->CI->config->item('maintenance') or config_item('maintenance') It does not work. Any suggestion on how to be able to use config item in hooks? Hook PHP Code: <?php PHP Code: $hook['pre_controller'] = array( RE: Config Item Not Working On Hooks - Narf - 02-03-2016 config_item() should work. get_instance() can't work before a controller is instantiated. RE: Config Item Not Working On Hooks - wolfgang1983 - 02-03-2016 (02-03-2016, 02:27 AM)Narf Wrote: config_item() should work. When I use config_item('maintenance') it seems to only work with post_controller and not pre_controller RE: Config Item Not Working On Hooks - Narf - 02-03-2016 (02-03-2016, 02:32 AM)wolfgang1983 Wrote:(02-03-2016, 02:27 AM)Narf Wrote: config_item() should work. Something else is wrong, not config_item(). CI itself uses this function even before 'pre_system'. RE: Config Item Not Working On Hooks - wolfgang1983 - 02-03-2016 (02-03-2016, 02:35 AM)Narf Wrote:(02-03-2016, 02:32 AM)wolfgang1983 Wrote:(02-03-2016, 02:27 AM)Narf Wrote: config_item() should work. In stead of creating a library to set a config item. At the bottom of my config.php file I now do this PHP Code: require_once (BASEPATH . 'database/DB.php'); And then when I use this config_item('maintenance') it now full works fine. |