Search code examples
phpclassfunctioncodeigniterloader

CodeIgniter: get_instance inside My_Lang


I found this useful Internationalization code:

http://pastebin.com/SyKmPYTX

everything works well except I am unable to use CI functions inside this class .

I want to set $languages and $special variable from DB .

but when I am using $CI =& get_instance(); in instance function its showing following error :

Fatal error: Class 'CI_Controller' not found in /system/core/CodeIgniter.php on line 231


Solution

  • The language class is loaded before the CodeIgniter instance exists, which is why you get the error.

    You can use a post_controller_constructor hook to set your variables.

    Here is a thread from the CodeIgniter forums where someone is tried to do something similar: http://codeigniter.com/forums/viewthread/108639/