问题
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:
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.
来源:https://stackoverflow.com/questions/7170370/integrate-phptal-template-engine-into-yii-framework