CodeIgniter - accessing $config variable in view

AlexA picture AlexA · Apr 13, 2010 · Viewed 134.1k times · Source

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 it explicitly.

Is there some way or trick to access $config variable from CI views without disturbing controllers with spare code?

Answer

Phil Sturgeon picture Phil Sturgeon · Apr 13, 2010

$this->config->item() works fine.

For example, if the config file contains $config['foo'] = 'bar'; then $this->config->item('foo') == 'bar'