I'm not sure if this is the best way but it can definitely help someone facing the same problems as I did. The scenario is simple, considering that you might use a settings table for your application and want to allow the owner/administrator to change various things such as site name, layout etc from the application itself you may present him with a form which saves the values of those settings so now you need to overwrite whatever is in the main.php configuration file. I added the following code in my bootstrap file (index.php) right after $yiiApp = Yii::createWebApplication ( $config );:

Yii::app ()->name = wb_setting ( 'SITE_NAME' );
Yii::app ()->language = wb_setting ( 'DEFAULT_LANGUAGE' );
Yii::app ()->theme = wb_setting ( 'DEFAULT_THEME' );
Yii::app ()->params->adminEmail = wb_setting ( 'ADMIN_EMAIL' );
Yii::app ()->charset = wb_setting ( 'DEFAULT_CHARSET' );

Where wb_setting is a shortcut function that I use to retrieve the value of a given setting from my db.



Published:10/03/2009
View The Entire Article