Hello:
I’m noodling around with some CJuiWidgets, and I’m noticing they each of a member variable called $theme, which sets the jQuery theme to use.
I’d like to propose a method of setting the default theme across all widgets, preferably in a configuration file, so as to automatically theme the entire site in one fell swoop.
What I’ve done locally, and appears to work is:
In framework/zii/widgets/jui/CJuiWidget.php, in the init function:
80 public function init()
81 {
82 if($this->theme == null)
83 {
84 $modules = Yii::app()->modules;
85 if(array_key_exists('jui', $modules) && array_key_exists('defaultTheme', $modules['jui']))
86 {
87 $this->theme = $modules['jui']['defaultTheme'];n
88 }
89 else
90 {
91 $this->theme = 'base';
92 }
93 }
94
95 $this->resolvePackagePath();
96 $this->registerCoreScripts();
97 parent::init();
98 }
And then in config/main.php:
22 'modules'=>array(
23 'jui' => array(
24 'defaultTheme' => 'cupertino'
25 ),
26 ),
This doesn’t feel ideal, but it achieves the ability to centralize the default theme in what I feel is the right place (the config file). If there’s a better way of implementing this, please let me know.
Comments and critiques are welcome.