Welcome Guest, Not a member yet? Register   Sign In
Add to global $config array
#1

[eluser]CrazyMerlin[/eluser]
Hey guys!

How would I add to the global config array?
I have an email config file and would like to add some default values in it so I can pick them up using $this->email->etc etc

Can it be done?

Thanks
Paul.
#2

[eluser]TheFuzzy0ne[/eluser]
You can create another config file and access that via the config library, or you can just stick the data in your config.php file:
Code:
$config['email_settings'] = array(
        'protocol' => 'sendmail',
        'mailpath' => '/usr/sbin/sendmail',
        'charset' => 'iso-8859-1',
        'wordwrap' => TRUE
    );

Then you can grab the array like this:
Code:
$email_config = $this->config->item('email_settings');
#3

[eluser]CrazyMerlin[/eluser]
Thanks man, that'll do it!
#4

[eluser]Webnet[/eluser]
I wish CI had a way to call array items using config->item().... something like
Code:
config->item('email_settings.protocol')
#5

[eluser]InsiteFX[/eluser]
It does if you read.

CodeIgniter Users Guide - Config Class
#6

[eluser]Webnet[/eluser]
I've read through that and I see no examples that require more than a single tier of nested array. It also appears to require the tier be named after the file.
#7

[eluser]Aken[/eluser]
You can always extend the class and make it do whatever you want.




Theme © iAndrew 2016 - Forum software by © MyBB