Class yii\smarty\Extension

Inheritanceyii\smarty\Extension
Source Code https://github.com/yiisoft/yii2-smarty/blob/master/Extension.php

Extension provides Yii-specific syntax for Smarty templates.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() yii\smarty\Extension
blockCss() Smarty block function plugin Usage is the following: yii\smarty\Extension
blockDescription() Smarty block function plugin Usage is the following: yii\smarty\Extension
blockJavaScript() Smarty block function plugin Usage is the following: yii\smarty\Extension
blockTitle() Smarty block function plugin Usage is the following: yii\smarty\Extension
compilerUse() Smarty compiler function plugin Usage is the following: yii\smarty\Extension
functionJs() Smarty template function to instantiate JsExpression yii\smarty\Extension
functionMeta() Smarty function plugin Usage is the following: yii\smarty\Extension
functionPath() Smarty template function to get relative URL for using in links yii\smarty\Extension
functionRegisterCssFile() Smarty function plugin Usage is the following: yii\smarty\Extension
functionRegisterJsFile() Smarty function plugin Usage is the following: yii\smarty\Extension
functionSet() Smarty function plugin Usage is the following: yii\smarty\Extension
functionUrl() Smarty template function to get absolute URL for using in links yii\smarty\Extension
modifierVoid() Smarty modifier plugin Converts any output to void yii\smarty\Extension

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getViewConstVal() Helper function to convert a textual constant identifier to a View class integer constant value. yii\smarty\Extension

Property Details

$smarty protected property
protected \Smarty $smarty null
$viewRenderer protected property

Method Details

__construct() public method

public void __construct ( $viewRenderer, $smarty )
$viewRenderer yii\smarty\ViewRenderer
$smarty \Smarty
blockCss() public method

Smarty block function plugin Usage is the following:

{registerCss} div.header {

background-color: #3366bd;
color: white;

} {/registerCss}

Supported attributes: key and valid HTML attributes for the style tag. Refer to Yii documentation for details.

public string blockCss ( $params, $content, $template, &$repeat )
$params
$content
$template \Smarty_Internal_Template
$repeat
blockDescription() public method

Smarty block function plugin Usage is the following:

{description}

The text between the opening and closing tags is added as
meta description tag to the page output.

{/description}

Supported attributes: none.

public string blockDescription ( $params, $content, $template, &$repeat )
$params
$content
$template \Smarty_Internal_Template
$repeat
blockJavaScript() public method

Smarty block function plugin Usage is the following:

{registerJs key='show' position='POS_LOAD'}

$("span.show").replaceWith('<div class="show">');

{/registerJs}

Supported attributes: key, position. Refer to Yii documentation for details. The position attribute is passed as text without the class prefix. Default is 'POS_READY'.

public string blockJavaScript ( $params, $content, $template, &$repeat )
$params
$content
$template \Smarty_Internal_Template
$repeat
blockTitle() public method

Smarty block function plugin Usage is the following:

{title} Web Site Login {/title}

Supported attributes: none.

public string blockTitle ( $params, $content, $template, &$repeat )
$params
$content
$template \Smarty_Internal_Template
$repeat
compilerUse() public method

Smarty compiler function plugin Usage is the following:

{use class="app\assets\AppAsset"} {use class="yii\helpers\Html"} {use class='yii\widgets\ActiveForm' type='block'} {use class='@app\widgets\MyWidget' as='my_widget' type='function'}

Supported attributes: class, as, type. Type defaults to 'static'.

public string compilerUse ( $params, $template )
$params
$template \Smarty_Internal_Template
functionJs() public method (available since version 2.0.9)

Smarty template function to instantiate JsExpression

Usage is the following:

{js assign='expr' expression='function(){alert('expression');}}'}

public string functionJs ( $params, \Smarty_Internal_Template $template )
$params array
$template \Smarty_Internal_Template
functionMeta() public method

Smarty function plugin Usage is the following:

{meta keywords="Yii,PHP,Smarty,framework"}

Supported attributes: any; all attributes are passed as parameter array to Yii's registerMetaTag function.

public string functionMeta ( $params, $template )
$params
$template \Smarty_Internal_Template
functionPath() public method

Smarty template function to get relative URL for using in links

Usage is the following:

{path route='blog/view' alias=$post.alias user=$user.id}

where route is Yii route and the rest of parameters are passed as is.

public string functionPath ( $params, \Smarty_Internal_Template $template )
$params array
$template \Smarty_Internal_Template
functionRegisterCssFile() public method

Smarty function plugin Usage is the following:

{registerCssFile url='@assets/css/normalizer.css'}

Supported attributes: url, key, depends and valid HTML attributes for the link tag. Refer to Yii documentation for details.

public string functionRegisterCssFile ( $params, $template )
$params
$template \Smarty_Internal_Template
functionRegisterJsFile() public method

Smarty function plugin Usage is the following:

{registerJsFile url='http://maps.google.com/maps/api/js?sensor=false' position='POS_END'}

Supported attributes: url, key, depends, position and valid HTML attributes for the script tag. Refer to Yii documentation for details. The position attribute is passed as text without the class prefix. Default is 'POS_END'.

public string functionRegisterJsFile ( $params, $template )
$params
$template \Smarty_Internal_Template
functionSet() public method

Smarty function plugin Usage is the following:

{set title="My Page"} {set theme="frontend"} {set layout="main.tpl"}

Supported attributes: title, theme, layout

public string functionSet ( $params, $template )
$params
$template \Smarty_Internal_Template
functionUrl() public method

Smarty template function to get absolute URL for using in links

Usage is the following:

{url route='blog/view' alias=$post.alias user=$user.id}

where route is Yii route and the rest of parameters are passed as is.

public string functionUrl ( $params, \Smarty_Internal_Template $template )
$params array
$template \Smarty_Internal_Template
getViewConstVal() protected method

Helper function to convert a textual constant identifier to a View class integer constant value.

protected mixed getViewConstVal ( $string, $default )
$string string

Constant identifier name

$default integer

Default value

modifierVoid() public method

Smarty modifier plugin Converts any output to void

public string modifierVoid ( $arg )
$arg mixed