Pretty often I need to access $config
variables in views.
I know I can pass them from controller to load->view()
.
But it seems excessive to do i
You can do something like that:
$ci = get_instance(); // CI_Loader instance
$ci->load->config('email');
echo $ci->config->item('name');
$config['cricket'] = 'bat';
in config.php file
$this->config->item('cricket')
use this in view
$this->config->item()
works fine.
For example, if the config file contains $config['foo'] = 'bar';
then $this->config->item('foo') == 'bar'
$this->config->item('config_var')
did not work for my case.
I could only use the config_item('config_var');
to echo variables in the view
This is how I did it. In config.php
$config['HTML_TITLE'] = "SO TITLE test";
In applications/view/header.php (assuming html code)
<title><?=$this->config->item("HTML_TITLE");?> </title>
Whenever I need to access config variables I tend to use: $this->config->config['variable_name'];