/ Published in: PHP
Credit: 'Jelmer' from CodeIgniter Forums
1. Create preferences.php in your application/config/ directory.
2. Add this to the controller that writes your config values to the database so that it will also write them to the preferences.php config file.
3. Add 'preferences' to the config array of your application/config/autoload.php file.
4. Access the values using $this->config->item(); like you would with any other config value.
5. Celebrate with a beer.
1. Create preferences.php in your application/config/ directory.
2. Add this to the controller that writes your config values to the database so that it will also write them to the preferences.php config file.
3. Add 'preferences' to the config array of your application/config/autoload.php file.
4. Access the values using $this->config->item(); like you would with any other config value.
5. Celebrate with a beer.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function _export_preferences() { $this->load->helper('file'); $preferences = $this->db->get('preferences'); $preferences = $preferences->result(); $preferences_file = '<?php'."\n\n"; foreach ($preferences as $row) { $preferences_file .= '$config[\''.addslashes($row->name).'\'] = \''.addslashes($row->value).'\';'."\n"; } write_file(APPPATH.'config/preferences.php', $preferences_file); }
URL: http://codeigniter.com/forums/viewthread/103684/#674817