Yii 1.1: smarty-view-renderer

Allows you to use Smarty templates in Yii

Note: Latest release and documentation are available at extension github page.

This extension allows you to use Smarty version 2 or 3 templates in Yii.



  • Yii 1.0 or above


  • Extract the release file under protected/extensions.
  • Download and extract libs folder contents of Smarty package under protected/vendors/Smarty.
  • Add the following to your config file 'components' section:
    'fileExtension' => '.tpl',
    //'pluginsDir' => 'application.smartyPlugins',
    //'configDir' => 'application.smartyConfig',


  • Smarty documentation.
  • Current controller properties are accessible via {$this->pageTitle}.
  • Yii properties are available as follows: {$Yii->theme->baseUrl}.
  • Used memory is stored in {$MEMORY}, used time is in {$TIME}.

Change Log

1.0.1 (available from github)

  • Smarty 3.1 compatibility (Sam Dark)


  • changed autoload handling to work also when Yii autoloader has been modified (cebe)
  • ensure Smarty does not use SMARTY_SPL_AUTOLOAD (cebe)


  • Added possiblity to configure smarty properties (CAUTION: behavior of $filePermission changed) (cebe)
  • Fixed issue with rendering Widgets within a template (cebe)


  • Fixed renderFile method (Sam Dark)
  • Fixed bug with autoload Smarty 3 files in *nix (maksimgrib)


  • Code cleanup and minor fixes.


  • Changed translation category to 'yiiext'.
  • New naming conventions.
  • readme_ru.
  • Added $Yii variable.


  • YiiExt naming conventions changed, see readme.
  • Smarty 3 comatibility.
  • t and link plugin functions.


  • Initial public release (Sam Dark)

Total 11 comments

#10428 report it
developerworks at 2012/10/27 04:06am
add to included path

Remenber to add the 'application.vendors.*' to application config import array

#8844 report it
bobv at 2012/07/03 04:13am
Error on github page.


Fatal error: Cannot use object of type stdClass as array in /var/lib/jenkins/workspace/yiiext.github.com/app/components/YiiextGithubApi.php on line 72

on the 'extension github page' (http://yiiext.github.com/extensions/smarty-renderer/index.html) for about the last week. Would really like to look at this!

#5913 report it
shark at 2011/11/24 07:18am
Re: widgets

Thank you!

#5912 report it
CeBe at 2011/11/24 07:11am

In Smarty there is a different syntax for arrays with []. You also have to return rendered content (3rd parameter true). example:

{$this->widget('zii.widgets.CDetailView', [
], true)}
#5911 report it
shark at 2011/11/24 06:57am
Using widgets


how do I use widgets?

I tired it:

{$this->widget('zii.widgets.CDetailView', array(
", expected one of">

Syntax Error In Template "/virtualweb/team.dev/testapp.dev/protected/modules/testapp/views/file/view.tpl" On Line 21 "'data'=>$model," - Unexpected "=>", Expected One Of: "","" , ")"

#5882 report it
CeBe at 2011/11/22 01:55pm

@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

#5699 report it
Muaid at 2011/11/03 08:47pm

i get error when loading. my fix is in file ESmartyViewRenderer.php from line 109 till 112

i think we should replace :

$this->smarty->plugins_dir[] = Yii::getPathOfAlias('application.extensions.Smarty.plugins');
    $this->smarty->plugins_dir[] = Yii::getPathOfAlias($this->pluginsDir);



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.

#5094 report it
andr2k at 2011/09/14 09:27am
how to use {extends}?

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)

#4596 report it
CeBe at 2011/07/25 06:28am
0.9.9 needs Smarty 3

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.

#1256 report it
baisword at 2009/10/12 09:49pm
how about Dwoo

i think dwoo is a better choice

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet