Welcome Guest, Not a member yet? Register   Sign In
saving custom config variables
#1

[eluser]AtlantixMedia[/eluser]
Hello,

I need to load several custom config variables in different parts of my application. I'm currently saving them in the $config array as CI suggests and retrieving them when I need to. However, I would prefer to save my config variables this way:

Code:
$country['us'] = 'United States';
$country['uk'] = 'United Kingdom';
etc

instead of:

Code:
$config['country'] = array('us' => 'United States', 'uk' => 'United Kingdom');

what would be the proper way to load those variables? a simple include file?

thanks in advance
#2

[eluser]ejangi[/eluser]
You could try overwriting the CI_Config class??? The offending line that is forcing you to use $config is on line 80 of the /system/libraries/Config.php file:
Code:
include(APPPATH.'config/'.$file.EXT);

if ( ! isset($config) OR ! is_array($config))
{
    if ($fail_gracefully === TRUE)
    {
        return FALSE;
    }        
    show_error('Your '.$file.EXT.' file does not appear to contain a valid configuration array.');
}
#3

[eluser]ejangi[/eluser]
Oopps... Accidentally double posted (was trying to edit the previous post, not quote it...)

The offending line is in fact:
Code:
if ( ! isset($config) OR ! is_array($config))
not that entire bit that I just pasted. Sorry! Tongue




Theme © iAndrew 2016 - Forum software by © MyBB