CodeIgniter Forums
Extending core: Retrieval of config values does not work - 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: Extending core: Retrieval of config values does not work (/showthread.php?tid=2822)



Extending core: Retrieval of config values does not work - El Forum - 08-26-2007

[eluser]Martin Penev[/eluser]
Hi guys,

I'am extending the language core script by using the attached script. And for some functions, I need to use some config values (stored in the config.php).

Somehow I just cannot use any CI objects and functions and I won't know why. How or what do I need to write in order to use CI's functions and config values?

Code:
<?php

class MY_Language extends CI_Language
{

    function My_Language()
    {
        parent::CI_Language();    
        $CI =& get_instance(); //<--- is this right?
    }
    
    function checkLanguageCookie()
    {
        //what code to retrieve a config value?
    }
    
    
}

?&gt;



Extending core: Retrieval of config values does not work - El Forum - 08-26-2007

[eluser]coolfactor[/eluser]
Code:
$value = $CI->config->item('key', 'sub_key?');



Extending core: Retrieval of config values does not work - El Forum - 08-26-2007

[eluser]Martin Penev[/eluser]
I'm not getting there at all. Already at the line "$CI =& get_instance()" i'm getting this error:

Quote:Fatal error: Call to undefined function: get_instance() in /home/moonplan/public_html/starmountain/dev/codeigniter/system/application/libraries/MY_Language.php on line 9



Extending core: Retrieval of config values does not work - El Forum - 08-26-2007

[eluser]coolfactor[/eluser]
Right.

The Language library is loaded just prior to that function becoming available. Move the get_instance() call out of the constructor and into one of your functions where you need it.