More explanations in theming

please, can the documentation be more explicative in how activate theming? i mean: 1 the code in application configuration file (main.php) 2 an example of a theme directory with subdirectorys (views?) 3 does skin files exists?

in particular I don't understand where explained "Contents under a theme directory should be organized in the same way as those under the application base path. "

If you want to activate a theme named "theme1", you can do so in app config as follows:



return array(


    ......


    'theme'=>'theme1',


);


And you should have the following directory structure:



WebRoot/


    protected/


    themes/


        theme1/


            css/


            images/


            views/


                system/


                layouts/


                site/


Now if we try to render a view named "view1" for SiteController, the rendering method will first look for view1.php under WebRoot/themes/theme1/views/site/view1.php. If found, this view is used insted of WebRoot/protected/views/site/view1.php.

Hope this explains better.   

[/code]

if I have 2 views (created with crud for example) that are exactly the same in terms of layout, is not sufficient to put css classes used in those views in a css file under /themes/theme1/main.css?

Unlike Prado, CSS files in Yii are not automatically included. You have to manually include them in your view using:



Yii::app()->clientScript->registerCssFile($cssUrl);


Of course, if you can access the head section, you can directly put <script> element in the head to load a CSS file.

Is there an equivalent concept to skins in Yii? If I want to use a CLinkPager widget in several different views, but I want to ensure the page labels are consistent in all views, what is the best way to do it?

Nope, Yii doesn't support skin at the moment. It is possible to implement this, but this will definitely degrade the performance. So we will see if more people are requesting for this feature.

It is also possible to implement this by yourself without hacking Yii. You will need to override CBaseController::widget()/beginWidget()/endWidget() so that once the widget instance is created, the method will look for a skin in the current theme to apply to the widget.

I'm having another tinker with this. I looked in to overriding CBaseController::widget() etc and notice that unlike other places in the code, it does not use CConfiguration::createObject to instantiate and populate the widget.

If CConfiguration::createObject was not called statically, it would be possible to override the implementation, and if CBaseController::widget (and other places like CController::createAction) used the non-static createObject method, it would be very simple to add support for 'skinning' virtually any class which was created using this method.

Is it possible to make createObject a non-static method of CApplication? That way it could be called through Yii::app()->createObject().