Welcome Guest, Not a member yet? Register   Sign In
Error on $ci =& get_instance();
#5

[eluser]PermanaJ[/eluser]
Thanks for the advice .. I just want to try all code igniter's feature ...

btw, I have try the hooks ...

Code:
function do_language() {
    $CI =& get_instance();

    $language_cookie = config_item('cookie_prefix').config_item('language_cookie');
    $language = config_item('language');

    if(isset($_COOKIE[$language_cookie])){
        $CI->config->set_item('language',$_COOKIE[$language_cookie]);
        $language = $_COOKIE[$language_cookie];
    }
    $path = '/';
    $expire = time() + 604800;

    setcookie($language_cookie, $language, $expire, $path);

    $CI->lang->load(config_item('language_file'),config_item('language'));
}

It works when the hook point is 'post_controller_constructor', but when I try to try at hook point 'pre_controller' it result an error message :
Quote:Fatal error: Call to a member function set_item() on a non-object in D:\Project\PHP\myapp\application\hooks\myhooks.php on line 9

I need to set the language before the controller initialized because I load language file at controller ...


Messages In This Thread
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 07:59 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:18 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:47 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:55 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 10:13 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 11:41 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB