Creating a custom view renderer
There are many PHP template engines out there. Yii offers only two template types out of the box: native PHP and Prado-like templates. If you want to use one of the existing template engines or create your own, you have to implement it if it's not yet implemented by the Yii community.
In this recipe we'll implement Smarty templates support.
Getting ready
Create a fresh Yii application using
yiic webapp.Get the latest Smarty 3 release from http://www.smarty.net/.
Extract contents of the
libsdirectory toprotected/vendors/smarty/.
How to do it...
Create
protected/extensions/smarty/ESmartyViewRenderer.php:<?php class ESmartyViewRenderer extends CApplicationComponent implements IViewRenderer { public $fileExtension='.tpl'; public $filePermission=0755; private $smarty; function init() { Yii::import('application.vendors.smarty.*'); spl_autoload_unregister(array('YiiBase','autoload')); require_once('Smarty.class.php'...