Difference between #1 and #2 of
How to use an application behavior to maintain runtime configuration

Revision #2 has been created by Maurizio Domba Cerin on Jun 17, 2011, 10:03:50 AM with the memo:

fixed typos
« previous (#1) next (#3) »

Changes

Title changed

How to user an application behavior for maintain runtime configuration

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

application, configuration, behavior

Content changed

In this tutorial will be explained a method forto manage some configuration runtime. [This excellent tutorial](http://www.yiiframework.com/wiki/26/setting-and-maintaining-the-language-in-application-i18n "") follows a similar approach, but requires to write a masterclass which all controllers are supposed to extend, following this wiki you can achieve the same by only editing only the configuration. This is often needed forto manage internationalization, themes and other confiugration that depends from the user. The most conmfortable way is to user an application behavior. In this example we save the language in the session, but it can also be saved in the database. Create a file in compomnents named ApplicationConfigBehavior and copy this code in it:

```php
[...]
/**
* ApplicationConfigBehavior is a behavior for the application.
* It loads additional config parame
nters that cannot be statically
* written in config/main
*/
[...]
/**
* Declares events and the event handler methods
* See yii documentation on behavio
ur
*/
public function events()
[...]
ForTo update the language we can use a widget (to be included in layout/main), for example:


**components/LangBox.php**

```php
[...]
26 0
25 followers
Viewed: 42 367 times
Version: 1.1
Category: How-tos
Written by: zaccaria
Last updated by: Pablovp
Created on: Jun 17, 2011
Last updated: 11 years ago
Update Article

Revisions

View all history