Welcome Guest, Not a member yet? Register   Sign In
Extending core: Retrieval of config values does not work
#1

[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;
#2

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

[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
#4

[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.




Theme © iAndrew 2016 - Forum software by © MyBB