Home

Awesome

Smarty view renderer

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

Resources

Requirements

Installation

<?php
// ...
'viewRenderer'=>array(
  'class'=>'application.vendor.smarty.ESmartyViewRenderer',
    'fileExtension' => '.tpl',
    //'pluginsDir' => 'application.smartyPlugins',
    //'configDir' => 'application.smartyConfig',
    //'prefilters' => array(array('MyClass','filterMethod')),
    //'postfilters' => array(),
    //'config'=>array(
    //    'force_compile' => YII_DEBUG,
    //   ... any Smarty object parameter
    //)
),

There are some more options on configuring Smarty properties now. Will add documentation soon.

Usage

	You have to set path without extension
	{extends file="application.views.layout.main"} 
	{include file="application.views.controller._form"}
	
	Also you can use regular Smarty syntax for file path wich relative to current `views` directory:
	{include file="controller/_form.tpl"}

Smarty Plugins

	{*Render widget without params*}
	{widget name="path.to.widget.Class"} 

	{*You can set params by passing it in the widget-function*}
	{widget name="Breadcrumbs" links=['Library'=>'#', 'Data'] someParam="someValue"}
  
 	{*Another syntax. *}
	{begin_widget name="bootstrap.widgets.TbModal" id='anotherModalDialog' options=[backdrop=>static] otherParam="value" [...]}
        	{*Widget object are accessible via {$widget} variable inside the block *}
        	{$widget->some_widget_method_or_variable} 
  	{/begin_widget} 
   {form name="product_form" id='form' type='horizontal' otherParam="value" [...]}
		{*Form object are accessible via variable with name equal to form name*}
        {$product_form->textFieldRow($this->model, 'name', ['class'=>'span5','maxlength'=>255])}
   {/form} 
  {t text="text to translate" cat="app"}
  {t text="text to translate" cat="app" src="en" lang="ru"}
  {t text="text to translate" cat="app" params=$params}
  {link text="test"}
  {link text="test" url="controller/action?param=value"}
  {link text="test" url="/absolute/url"}
  {link text="test" url="http://host/absolute/url"}