Codeigniter return config file as array with autoload enabled
Posted
by Fverswijver
on Stack Overflow
See other posts from Stack Overflow
or by Fverswijver
Published on 2010-05-28T18:42:44Z
Indexed on
2010/05/28
21:02 UTC
Read the original article
Hit count: 231
So I'm using CodeIgniter to build a website and I've made it so that all my specific settings are stored in a config file that's automatically loaded. I've also built a page that loads the settings file, makes a nice little table and allows me to edit everything from that page, afterwards it saves the entire page again (I know I could've done the same with a database but I want to try it this way).
My problem is that I can't seem to use this bit when autoloading of my config file is enabled, but when I disable autoloading I can't seem to manually load it, it never finds my variables. So what I'm doing here is just taking all values from the config file and putting them in a single array so I can pass this array onto my settings administration page (edit/show all settings).
$this->config->load('site_settings', TRUE);
$data['settings'] = $this->config->item('site_settings');
...
$this->load->view('template', $data);
config/site_settings.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['header_img'] = './img/header/';
$config['copyright_text'] = 'Copyright Instituto Kabu';
$config['copyright_font'] = './system/fonts/motoroil.ttf';
$config['copyright_font_color'] = 'ffffff';
$config['copyright_font_size'] = '32';
© Stack Overflow or respective owner