I have created a custom configuration file for my custom CMS I am building using CodeIgniter. I want to have a "Configuration" page in the CMS that allows the user to save a contact email address and other variables.
I want to allow the user to set these config variables on the fly from the admin CP but I am having trouble doing so.
I found this article here: Dynamically updating config data codeigniter which asks a similar question but the answer is not exactly what I was looking for.
Is it possible to update a config file permanently on the fly from a controller? Right now my code looks like this:
$this->config->load('cms_config');
//load the initial view
$this->data['subview'] = 'admin/setup/index';
$this->load->view('admin/_layout_main', $this->data);
//validate form
if($this->form_validation->run('site_config') == TRUE) {
$this->config->set_item('contact_email', $this->input->post('contact_email'));
}
but this doesn't seem to update the file at all. In fact, nothing seems to happen upon form submit.
This is one of the design limitations I have encountered while working on my own CMS. configuration being inside the framework files. I then though of using a second database (SQLite for instance) to bootstrap extra configuration data but then faced a second limitation of CI as it doesn't support multiple databases at once. The only remaining option is to hard edit the config files themselves in a different context, a custom files or codeigniter hooks could do the job. or an installation controller (as implemented in pyro CMS)
If you would like to discuss more cms design issues let me know as I'm working on similar things.
Good luck.