Welcome Guest, Not a member yet? Register   Sign In
How to access a config item from within the config file
#1

[eluser]mradlmaier[/eluser]
Hello All

Maybe somebody know the answer about this problem:
How to access a config item from within the same config file...

Code:
$config['home_img_tag'] = 'some html' . $this->config->item('base_url') . 'some html';

The above does not seem to work...
Do I need to create an instance variable of CI?
And if so, how is the correct code?

Michael
#2

[eluser]xwero[/eluser]
If it's in the same file you can do
Code:
$config['home_img_tag'] = 'some html' . $config['base_url'] . 'some html';
If you want to access other config files, you need to include the file the setting is in and prevent the included array to get overwritten.
Code:
include(APPPATH.'config/other_config.php');
$other_config = $config;
unset($config);
// $config of the file itself
#3

[eluser]mradlmaier[/eluser]
Sorry for asking an obvious question,
The correct way to this is simply:

Code:
$config['home_img_tag'] = 'some html'. $config['base_url'] . 'some html';


Michael
#4

[eluser]mradlmaier[/eluser]
Thank you xwero,

u were 5 minutes faster than me... :-)

Michael




Theme © iAndrew 2016 - Forum software by © MyBB