Updating config items through a form? |
[eluser]Joshee[/eluser]
I have been working on making my own forum with CodeIgniter and I have been trying to update config items through a form (For the admin. Updating items such as the site name, logo image, etc.) For some reason, the form runs correctly, but the items don't get updated. And I'm not getting any sort of error. Everything is working correctly, the config items just aren't updating. But if I say $this->config->set_item('item_name', 'new_value'); on it's own, it updates how it should. Can anyone help me? Controller code: Code: function update_settings() { Model code: Code: function update_settings() { View code: Code: <?php echo form_open('admin/update_settings'); ?>
[eluser]ReLexEd[/eluser]
$this->config->set_item() only sets the item for the current execution, not in the config-file. If you wish to change the config-item in the file you'll have to write them to the appropriate config-file yourself.
[eluser]Joshee[/eluser]
So there is no way I would be able to update the config items through a form like I am trying to do?
[eluser]Twisted1919[/eluser]
You can with MY_Config: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 2) Generate your database table with create_table() method; 3) When you want to save a item into database, you do save_db_item() 4) To load all the items from database, use load_db_items() in something like MY_CONTROLLER 5) Access the database items after you called load_db_items() with item() method;
[eluser]SitesByJoe[/eluser]
I've been planning to write this code but you beat me to it! Nice one on the "MY_config!"
[eluser]Eric Barnes[/eluser]
Here is one I use as a library: https://github.com/ericbarnes/ci-settings
[eluser]Joshee[/eluser]
[quote author="Eric Barnes" date="1297199904"]Here is one I use as a library: https://github.com/ericbarnes/ci-settings[/quote] Thank you for that, Eric! That worked for my problem!
[eluser]predat0r[/eluser]
[quote author="Eric Barnes" date="1297199904"]Here is one I use as a library: https://github.com/ericbarnes/ci-settings[/quote] Hi, question: what is autoload in the settings lib? Thanks |
Welcome Guest, Not a member yet? Register Sign In |