I have modularized my web app, please see the structure below:
protected
modules
articles
forum
themes
default
articles
Now is it possible to have a different theme folder for the forum module ? I do not want to use the "default" theme for my forum module. So, is it possible to do something like this ?
protected
modules
articles
forum
themes
default
articles
forum
bingo
So, what I am trying to achieve is, to store all the themes for the forum module in different theme. I am aware that the CWebModule has the method setLayoutPath(), but it is going to set only the main layout, and not the whole theme.
Hi, after I’ve played a bit more, I found out that the CWebModule has 2 class properties that can effect the layouts and views folder. They are the: “layoutPath”, and the “viewPath”.
In order to have custom layout and view for the module can be achieved by overriding these 2 properties in the module config file, please see the structure below:
WWWRoot
yoursitename
protected
modules
forum
config
main.php
Within the main.php, write:
<?php
return array (
'layoutPath' => 'path/to/layouts', //defaults to protected/views/layouts
'viewPath' => 'path/to/views' //defaults to protected/views
);
Now your module (in this example "forum") will then get its layout file and views from the location specified in the config file.
So to the end, each module in within Yii Application may have its own layout and their own view. But, if I may suggest, maybe it would be better to add the "theme" as one of the CWebModule class properties. So in the future we can do this: