Integrate PHPTAL template engine into yii framework

807 Views Asked by At

I'm wondering that how to integrate PHPTAL into yii framework? I'm using PHPTAL for a long time and it's nice template engine. Although Yii allows integrate another template engine into framework but it still does not support PHPTAL.

Thanks for your help.

1

There are 1 best solutions below

2
On

Have a look at this extension for Smarty template engine: smarty-view-renderer

Basically, you write a Component for Yii that implements IViewRenderer. Then override init() and implement renderFile(), and then in your main.php config file, you set viewRenderer to your Component class. Something like this:

'components' => array(
    ...
    'viewRenderer'=>array(
        'class'=>'application.extensions.path.to.your.class',
        'fileExtension' => '.ext',  // file extension to be handled by PHPTAL
        //other configurations for your component
    ),

and it will work like a charm.

But if you don't insist on PHPTAL, Smarty is there ready for you.