CodeIgniter Forums
set_item for custom configs - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: set_item for custom configs (/showthread.php?tid=14735)



set_item for custom configs - El Forum - 01-13-2009

[eluser]Unknown[/eluser]
Is there a way to set the value of a custom config. I can retrieve a custom config but I can't find a way to set it.

Code:
echo $this->config->item('base_url') . '<br>';
echo $this->config->item('base_url', 'myconfig') . '<br>';

$this->config->load('myconfig', TRUE);
echo $this->config->item('base_url') . '<br>';
echo $this->config->item('base_url', 'myconfig') . '<br>';

// This sets the base config
$this->config->set_item('base_url', 'new_url');
// How do I set the myconfig setting???
$this->config->set_item('base_url', 'new_myconfig_url', "myconfig");

echo $this->config->item('base_url') . '<br>';
echo $this->config->item('base_url', 'myconfig') . '<br>';



set_item for custom configs - El Forum - 01-13-2009

[eluser]maesk[/eluser]
A workaround could be to not call the config item base_url but something else and not use TRUE when you load your custom config, then you could set it by its new name. To call it base_url can create confusion anyways. But it's strange that this (setting an item in custom config) is not in the User Guide. The set_item() function seems to take only two arguments, name and value.