Welcome Guest, Not a member yet? Register   Sign In
Editing a Config File
#1

[eluser]Matt Egan[/eluser]
I'm working on a project of mine (State Tech Fair Actually) and its looking really nice. The last feature I'm implementing is a way to edit some configuration in a tab on my admin panel.

The configuration holds stuff like blog name, page title, about the blog, how many posts to display per page and username and password. What I'm wondering is, how would I go about letting the user edit this? Would it be easier to pull config from a database?

Thanks for the help guys, if you 'd like to see the project, I'd be glad to show it to you/ upload the code.
#2

[eluser]TheFuzzy0ne[/eluser]
A database is probably your best option, although you could also serialize an array and store it in a file, then you can simply unserialize it when you need to load it.
#3

[eluser]gyo[/eluser]
I agree, a database is the best option.
Anyway, if you don't know it already, the Config class gives you the ability to dynamically set config items directly in the files:

http://ellislab.com/codeigniter/user-gui...onfig.html
#4

[eluser]TheFuzzy0ne[/eluser]
When you dynamically set a configuration item that way, it's only overrides/inserts the variables for the rest of that request. It doesn't write those changes to a file. If it does, then I'll eat my own underpants.
#5

[eluser]gyo[/eluser]
Ooops... thanks FuzzyOne!
I tried it cause you made me curious, and it doesn't work! So basically it's just a temporary override, or eventually to pass data all around in the application?

Anyway this part of the guide is a bit confusing (maybe it's my english):

Code:
If you would like to dynamically set a config item or change an existing one, you can so using:
$this->config->set_item('item_name', 'item_value');

Sorry, I just learnt something new Wink
#6

[eluser]Matt Egan[/eluser]
Yeah, I went ahead and created 2 functions in my model to get and update the config table in my database. Thanks for the help Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB