How to create themes in yii framework?

Workonphp picture Workonphp · Jan 16, 2013 · Viewed 8.4k times · Source

I am new to Yii framework. I was working on drupal earlier, and the theming of drupal made sites are not difficult to manage. But I just want to know that how to create theme for the site with Yii framework.

I have gone through many sites, but still don't know where to start. For example I have checked http://www.yiiframework.com/doc/guide/1.1/en/topics.theming.

Now my doubts are:

  1. Where to start for creating Yii themes? Suppose I want to change drupal theme to Yii, How can I do this?
  2. Is it possible to have different theme for different pages? Like in drupal by using themekey module, we can have multiple theme for different pages.

It will be good if anybody will explain it step by step.

Answer

Brett Gregson picture Brett Gregson · Jan 16, 2013

You can edit the layouts (protected/views/layouts/..). These are the wrapper views which are rendered around individual views rendered with render(), for example the site/index calls the index view (located at protected/views/index.php) using:
$this->render("index");

You can change the layout per action using:
$this->layout = "differentlayout";

You can set the layout for all actions within a Controller using:
public $layout='//layouts/differentlayout';

Obviously each layout can have a custom structure and loads different CSS and JS files. I know this isn't using the themes and theming but it is by far the most common way of customizing the look and feel of a Yii project

Here are some helpful links regarding YII theme development: