Yii Framework Forum: Theming Modules - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Theming Modules Rate Topic: -----

#1 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 16 January 2010 - 01:37 AM

Hi All,

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.

Could anyone please help ?

Thank you!
0

#2 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 17 January 2010 - 10:42 AM

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:

<?php
   return array (
      'theme' => 'path/to/theme' 
   );


Sincerely,
110% Revolutioner
0

#3 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 06 May 2010 - 01:56 AM

Mmm I have the same problem... why in themes we cannot just override modules?

like:

/themes/default/modules/user/views/login.php

No need to config anything in modules (which are mostly from 3rd party)
0

#4 User is offline   Onman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 175
  • Joined: 26-December 09
  • Location:The Netherlands

Posted 06 May 2010 - 09:23 AM

What both of you guys want to do is all possible.

Read the topic about theming in Yii.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users