• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use a $config setting in a pre_system hook [SOLVED]

#1
[eluser]JoostV[/eluser]
I would like to use a config setting in a pre_system hook. Can anybody tell me if and how this can be done?

Specifically, I would like to set some URL-related constants like C_ROOT_URL in my pre_system bootstrap hook class, using config.php's
Code:
$config['base_url']

I already set stuff in this class like
Code:
// Set environment we are currently in
$rootpath = dirname(realpath(BASEPATH)) . DIRECTORY_SEPARATOR;
if (stristr($rootpath, 'O:\htdocs')) {
    define('C_ENVIRONMENT', 'development');
}
elseif (stristr($rootpath, '/home/testuser/domains/thisismytestdomain.com')) {
    define('C_ENVIRONMENT', 'staging');
}
else {
    define('C_ENVIRONMENT', 'production');
}

#2
[eluser]wiredesignz[/eluser]
Try using the config_item() function which resides in codeigniter/Common.php and is loaded pretty early on in the bootstrap. ie:
Code:
$base_url = config_item('base_url');

#3
[eluser]JoostV[/eluser]
Works! Thanks!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.