This extension allows you to use Smarty version 2 or 3 templates in Yii.
protected/extensions.libs folder contents of Smarty package under protected/vendors/Smarty.'viewRenderer'=>array( 'class'=>'application.extensions.yiiext.renderers.smarty.ESmartyViewRenderer', 'fileExtension' => '.tpl', //'pluginsDir' => 'application.smartyPlugins', //'configDir' => 'application.smartyConfig', ),
Total 8 comments
Thank you!
In Smarty there is a different syntax for arrays with []. You also have to return rendered content (3rd parameter true). example:
Hi,
how do I use widgets?
I tired it:
@andr2k: just created an issue for you: https://github.com/yiiext/smarty-renderer/issues/4
@muaid: this has just been fixed in version 1.0.1, you can download it from github: https://github.com/yiiext/smarty-renderer/tags
i get error when loading. my fix is in file ESmartyViewRenderer.php from line 109 till 112
i think we should replace :
with
scince there is setter and getter in Smarty and will issue error now.
my smarty version (in vendors folder) is 3.1.4
thank you.
How to extend templates using {extends} syntax?
When I try to use {extends file="view.tpl"} it cannot find the file. When I use {extends file="{$smarty.current_dir}/view.tpl"} it doesn't work because of the following error: "[...]a variable file attribute is illegal"
Current template and "view.tpl" are in the same directory.
The problem exists if Smarty was previously used to render a file in another directory.
Workaround: add this code to renderFile function body:
$this->smarty->template_dir = dirname($sourceFile)
Since 0.9.9 this extension will only work with Smarty 3.
You have to update to Smarty 3 or stay with Smarty 2 and 0.9.8. There are also some issues with some Smarty 3 release candidates, so you should use Smarty 3.0.8 or higher.
i think dwoo is a better choice
Leave a comment
Please login to leave your comment.