Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create themes in yii framework?

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.

like image 863
Workonphp Avatar asked Jan 16 '13 07:01

Workonphp


People also ask

Is Yii framework easy to learn?

Yii certainly requires good programming skills, PHP, at least basics of object oriented programming. If you know all that, then you can start in a week. After a month or two you'll be doing things correctly. After about 3 months you should be comfortable.

Is Yii hard to learn?

Yii has a low-entry barrier. In other words, it is really easy to learn. Developers describe it as a PHP framework that is most simple.

How does Yii framework work?

Yii framework uses “Gii” tool, which is a web-based code scaffolding tool that is used to create code quickly. Using this, we can create templates in models, controllers, forums, modules, extensions, CRUD controlled actions, and views.

Is Yii framework good?

Yes, it is! Yii is a fast, secure, and efficient PHP framework. Flexible yet pragmatic. Works right out of the box.


1 Answers

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:

  • http://www.yiiframework.com/doc/guide/1.1/en/basics.view
  • http://www.yiiframework.com/wiki/249/understanding-the-view-rendering-flow/
  • http://mushfiq.me/2011/05/30/creating-a-yii-application-theme-from-a-html-template/
like image 170
Brett Gregson Avatar answered Oct 17 '22 07:10

Brett Gregson