Welcome Guest, Not a member yet? Register   Sign In
Change $config item.
#1

[eluser]Young Caveman[/eluser]
Ok, i heard something about
Code:
$this->config->set_item('item_name', 'item_value');
in the user guide. But this is a function that overrides current value, right? I want to know if there's something that can help to change permanently that value, fiscally in the php file.

I read two three posts here around but haven't noticed nothing that can easily help without using external methods (PEAR, for example).

Thanks, in advance.

Don ~ Alberto
#2

[eluser]frenzal[/eluser]
to do so permanantly would mean writing over the config file
#3

[eluser]Derek Allard[/eluser]
We just introduced a constants.php file in the config folder (its only in the svn) that might be interesting to you. What would you use these values for, and why wouldn't you just open up the file in a text editor and change them permanently (that's what I'd do).

Oh, and WELCOME TO CODEIGNITER Wink
#4

[eluser]John Fuller[/eluser]
I would just create a different configuration scheme separate from the CI config files. I have been using Yaml files for my own system. I just created a different config folder, dropped in Spyc and wrote a small class to tie everything together. The library has methods for reading and writing Yaml files.

You could do something similar with XML if that's your preferred flavor.
#5

[eluser]webthink[/eluser]
If the change to the config option is permanent just change it in the config file.
If it's semi permanent, perhaps based off of some condition, you could use a hook with $this->config->set_item() to change it at the start of every (or where necessary) request.
#6

[eluser]louis w[/eluser]
I like the idea of CI allowing you to re-export your config files. I think PEAR::Config does this.

@Derek: What is constants.php for? I can not download the latest from svn until tonight.
#7

[eluser]Derek Allard[/eluser]
Take a look at the log and file comments tonight and let me know if its still unclear louis, I'll be happy to walk you through it if there's still confusion.
#8

[eluser]Young Caveman[/eluser]
Thanks to you all, at first.
Then, apolozige cause I'm not english, but I hope you can understand me well.

I need to set some infos that the user (it's a CMS) can change whenever he/she wants, like app title, style folder, etc.
While in the config file the ['style'] value is set once, when coding the controllers I have to use $this->config->set_item(); for each controller in which i want to overwrite the config.php value, but i hope there's something that can help me in a better way.

I set up a class which can retrieve config informations and pass them to the views, so the idea was to call these infos just once. If i can overwrite permanently that values to the config.php, i won't have to call the overriding in every controller.

"We just introduced a constants.php file in the config folder (its only in the svn) that might be interesting to you.[...]" Yeah that's interesting. Wink I'm gonna check the log Wink

"Oh, and WELCOME TO CODEIGNITER". Thanks Wink

I wrote as well as i could, this is english that my school's teachin me TongueTongue

PS John, I'll take a look, thanks Wink
#9

[eluser]Derek Allard[/eluser]
You english is great Sensuous. What you are doing sounds correct to me. I wonder if its even worth having it as a config value if you are changing it for every user anyhow... might make more sense to store that info in a session... not sure - it would depend on how you've got things set up.
#10

[eluser]Young Caveman[/eluser]
[quote author="Derek Allard" date="1207683553"]You english is great Sensuous. What you are doing sounds correct to me. I wonder if its even worth having it as a config value if you are changing it for every user anyhow... might make more sense to store that info in a session... not sure - it would depend on how you've got things set up.[/quote]

Uhm...

That are values that only administrator can change. I mean, such as the title for the application, for example.

I thought also about storing infos in a MySQL db. Although this can help the user to create his own configurations, and switch them whenever he wants to, I wanted to know if there's a solution using CI config file.




Theme © iAndrew 2016 - Forum software by © MyBB