将php模板引擎集成到yii框架中


Integrate PHPTAL template engine into yii framework

我想知道如何将PHPTAL集成到yii框架中?我使用PHPTAL很长一段时间,它是一个很好的模板引擎。虽然Yii允许在框架中集成另一个模板引擎,但它仍然不支持PHPTAL。

谢谢你的帮助。

看看这个扩展Smarty模板引擎:Smarty -view-renderer

基本上,您为Yii编写一个实现IViewRenderer的组件。然后覆盖init()并实现renderFile(),然后在您的main.php配置文件中,将viewRenderer设置为您的Component类。像这样:

'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
    ),

,它会像一个魅力。

但是如果你不坚持使用PHPTAL, Smarty已经为你准备好了