I have an init() function overwritten in my Controller class. I wanted to change application configuration there. It has to be done dynamically (there) and can’t be permanent, because part of configuration should change only upon some condition is met.
I was able to test, that this thing works, by dynamically changing application langauge:
public function init()
{
Yii::app()->configure
(
array
(
'language'=>'en_us'
)
);
)
but I failed completely, when I tried to change some extension configuration:
public function init()
{
Yii::app()->configure
(
array
(
'components'=>array
(
'bootstrap'=>array
(
'class'=>'ext.bootstrap.components.Bootstrap',
'responsiveCss'=>false
)
)
)
);
}
Here I’m trying to force Bootstrap extension to use responsive design, in case user is using a mobile browser. I don’t know why, but it fails completely. Not only I can’t change Bootstrap configuration this way, but even nulling (emptying) whole extension array does not work – i.e. I can still use it in my app.
What am I doing wrong? Why I can change some base app settings (language), but can’t do the same with extension configuration.
Alternatively, maybe someone knows a betterway (directly in application config) to set one or more extension parameters, when a browser is detected to be a mobile one (I have a great function that works basing only on $_SERVER[‘HTTP_USER_AGENT’] and regular expression, does not uses anything out of Yii, so can be called outsite Yii or when Yii aplication isn’t even initiated).