Store site configuration on database - 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: Store site configuration on database (/showthread.php?tid=21810) |
Store site configuration on database - El Forum - 08-21-2009 [eluser]itibook[/eluser] Hi all, pretty new here, so feel free to some links if you think I missed something. Just to be clear I spent a couple of hours on the forum and google, but couldn't find an answer, so that's why I am posting... I would like to be able to set some basic configuration fields (e.g. website name, website email, etc) in a database table and make sure that they get loaded at each page so that I can re-user those value in each model/view. The end game is to have those configuration settings editable in the admin panel. It's not rocket science, I am sure, but I can't seem to grasp where and how I should do that. thanks in advance Luca Store site configuration on database - El Forum - 08-21-2009 [eluser]GSV Sleeper Service[/eluser] sounds like a perfect use for hooks. http://ellislab.com/codeigniter/user-guide/general/hooks.html Store site configuration on database - El Forum - 08-21-2009 [eluser]itibook[/eluser] Thanks. It looks indeed like the right match, I will search better on that side. Thanks again Store site configuration on database - El Forum - 08-21-2009 [eluser]itibook[/eluser] just posting here in case anyone else has the same problem and looks for a solution: I found this two links that gave me the direction... http://www.echovsprint.com/2009/04/role-based-access-control-in-codeigniter-using-hooks/ http://codeigniterandjquery.blogspot.com/2008/01/magic-of-hook-in-ci.html I settled for having a hook that retrieves the settings from my database and defines them as constants so that I can call each setting from any MVC again thanks GSV Sleeper Service for giving me the right direction... ciao Luca Store site configuration on database - El Forum - 08-21-2009 [eluser]Dark Preacher[/eluser] I'll try to suggest my own solution, as I've done before (and doing now). First create table "preferences" in your database: Code: CREATE TABLE `preferences` ( Code: function get_pref($name){ Code: <title><?=$this->m_common->get_pref('site_name')?></title> Store site configuration on database - El Forum - 08-21-2009 [eluser]itibook[/eluser] Hi Dark Preacher, I am basically doing the same, but with the hooks solution suggested it means that the preferences are always available as they are loaded before anything else, basically they are like config variables. anyway, thanks for the suggestion, hadn't thought of it, so it might come in handy for other cases. ciao Luca |