Dear everyone,
My question
When we select different theme. How can we make Yii select a different asset file to publish according to theme.
Default theme
In config file…
'clientScript'=>array(
'packages'=>array(
'myPackage'=>array(
'basePath'=>'application.assets.myPackage',
'js'=>array('js/myPackage.js'),
'css'=>array('css/myPackage.css'),
'depends'=>array('jquery'),
),
),
),
When I call…
Yii::app()->clientScript->registerCoreScript('myPackage');
Yii publishes file normally.
But when I change theme into some other theme than default, how can I tell Yii to use different file to publish?
My workaround
I manually alter the package array before Yii renders the page
Yii::app()->clientScript->packages['myPackage'] = array(...) // Whatever new config for the theme I want it to be
But I think there has to be a better way… to do it in config file.
Thanks.