Properties

$cache_id

$cache_id : string

cache_id

Type

string

$compile_id

$compile_id : string

$compile_id

Type

string

$caching

$caching : boolean

caching enabled

Type

boolean

$cache_lifetime

$cache_lifetime : integer

cache lifetime in seconds

Type

integer

$template_resource

$template_resource : string

Template resource

Type

string

$mustCompile

$mustCompile : boolean

flag if compiled template is invalid and must be (re)compiled

Type

boolean

$properties

$properties : array

special compiled and cached template properties

Type

array

$required_plugins

$required_plugins : array

required plugins

Type

array

$smarty

$smarty : \Smarty

Global smarty instance

Type

\Smarty

$block_data

$block_data : array

blocks for template inheritance

Type

array

$variable_filters

$variable_filters : array

variable filters

Type

array

$used_tags

$used_tags : array

optional log of tag/attributes

Type

array

$allow_relative_path

$allow_relative_path : boolean

internal flag to allow relative path in child template blocks

Type

boolean

$_capture_stack

$_capture_stack : array

internal capture runtime stack

Type

array

$source

$source : \Smarty_Template_Source

Type

\Smarty_Template_Source

$compiled

$compiled : \Smarty_Template_Compiled

Type

\Smarty_Template_Compiled

$cached

$cached : \Smarty_Template_Cached

Type

\Smarty_Template_Cached

Methods

fetch()

fetch(string  $template = null, mixed  $cache_id = null, mixed  $compile_id = null, object  $parent = null, boolean  $display = false, boolean  $merge_tpl_vars = true, boolean  $no_output_filter = false) : string

Renders and returns a template.

This returns the template output instead of displaying it.

Parameters

string $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

boolean $display

true: display, false: fetch

boolean $merge_tpl_vars

if true parent template variables merged in to local scope

boolean $no_output_filter

if true do not run output filter

Returns

string —

rendered template output

display()

display(string  $template = null, mixed  $cache_id = null, mixed  $compile_id = null, object  $parent = null) : void

Renders the template.

This displays the contents of a template. To return the contents of a template into a variable, use the fetch() method instead.

As an optional second and third parameter, you can pass a cache ID and compile ID.

A fourth parameter can be passed which passes the parent scope that the template should use.

Parameters

string $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

isCached()

isCached(string|object  $template = null, mixed  $cache_id = null, mixed  $compile_id = null) : boolean

Returns whether the template is cached.

Note that calling this method will load the template into memory. Subsequent calls to fetch() or display() will not reload the template file. Calling clearCache() may also have no effect if this method has returned true.

Parameters

string|object $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

Returns

boolean —

The template's cache status

createData()

createData(object|null  $parent = null) : \Smarty_Data

Returns a new data object.

Data objects are used to create scopes for assigned variables. They can be used to have control which variables are seen by which templates.

Parameters

object|null $parent

Optional link to a parent scope

Returns

\Smarty_Data

data object

registerPlugin()

registerPlugin(string  $type, string  $tag, callable  $callback, boolean  $cacheable = true, array|null  $cache_attr = null) : \Smarty_Internal_TemplateBase

Registers plugin to be used in templates

Parameters

string $type

plugin type

string $tag

name of template tag

callable $callback

PHP callback to register

boolean $cacheable

if true (default) this fuction is cachable

array|null $cache_attr

caching attributes if any

Throws

\SmartyException

when the plugin tag is invalid

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

unregisterPlugin()

unregisterPlugin(string  $type, string  $tag) : \Smarty_Internal_TemplateBase

Unregister Plugin

Parameters

string $type

of plugin

string $tag

name of plugin

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerResource()

registerResource(string  $type, \Smarty_Resource|array<mixed,\Smarty_Resource>  $callback) : \Smarty_Internal_TemplateBase

Registers a resource to fetch a template

Parameters

string $type

name of resource type

\Smarty_Resource|array<mixed,\Smarty_Resource> $callback

Instance of Smarty_Resource, or array of callbacks to handle resource (deprecated)

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

unregisterResource()

unregisterResource(string  $type) : \Smarty_Internal_TemplateBase

Unregisters a resource

Parameters

string $type

name of resource type

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerCacheResource()

registerCacheResource(string  $type, \Smarty_CacheResource  $callback) : \Smarty_Internal_TemplateBase

Registers a cache resource to cache a template's output

Parameters

string $type

Name of cache resource type

\Smarty_CacheResource $callback

instance of Smarty_CacheResource to handle output caching

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

unregisterCacheResource()

unregisterCacheResource(string  $type) : \Smarty_Internal_TemplateBase

Unregisters a cache resource

Parameters

string $type

name of cache resource type

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerObject()

registerObject(  $object_name, object  $object_impl, array  $allowed = array(), boolean  $smarty_args = true, array  $block_methods = array()) : \Smarty_Internal_TemplateBase

Registers object to be used in templates

Parameters

$object_name
object $object_impl

the referenced PHP object to register

array $allowed

list of allowed methods (empty = all)

boolean $smarty_args

smarty argument format, else traditional

array $block_methods

list of block-methods

Throws

\SmartyException

if any of the methods in $allowed or $block_methods are invalid

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

getRegisteredObject()

getRegisteredObject(string  $name) : mixed

Returns a reference to a registered object.

Parameters

string $name

object name

Throws

\SmartyException

if no such object is found

Returns

mixed

unregisterObject()

unregisterObject(string  $name) : \Smarty_Internal_TemplateBase

unregister an object

Parameters

string $name

object name

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerClass()

registerClass(  $class_name, string  $class_impl) : \Smarty_Internal_TemplateBase

Registers static classes to be used in templates

Parameters

$class_name
string $class_impl

the referenced PHP class to register

Throws

\SmartyException

if $class_impl does not refer to an existing class

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerDefaultPluginHandler()

registerDefaultPluginHandler(callable  $callback) : \Smarty_Internal_TemplateBase

Registers a default plugin handler

A default plugin handler gets called on undefined tags.

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerDefaultTemplateHandler()

registerDefaultTemplateHandler(callable  $callback) : \Smarty_Internal_TemplateBase

Registers a default template handler

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerDefaultConfigHandler()

registerDefaultConfigHandler(callable  $callback) : \Smarty_Internal_TemplateBase

Registers a default template handler

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

registerFilter()

registerFilter(string  $type, callback  $callback) : \Smarty_Internal_TemplateBase

Registers a filter function

Parameters

string $type

filter type

callback $callback

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

unregisterFilter()

unregisterFilter(string  $type, callback  $callback) : \Smarty_Internal_TemplateBase

Unregisters a filter function

Parameters

string $type

filter type

callback $callback

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

loadFilter()

loadFilter(string  $type, string  $name) 

Load a filter of specified type and name

Parameters

string $type

filter type

string $name

filter name

Throws

\SmartyException

if filter could not be loaded

unloadFilter()

unloadFilter(string  $type, string  $name) : \Smarty_Internal_TemplateBase

unload a filter of specified type and name

Parameters

string $type

filter type

string $name

filter name

Returns

\Smarty_Internal_TemplateBase

Self-reference to facilitate chaining

assign()

assign(array|string  $var, mixed  $value = null) : \Smarty_Internal_Data

Assigns $var to the variable in $varname. If an associative array is passed as the only parameter, it is a mapping of variables to assign to the values to assign to them.

Parameters

array|string $var

the template variable name(s)

mixed $value

the value to assign

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assignGlobal()

assignGlobal(string  $varname, mixed  $value = null) : \Smarty_Internal_Data

Assigns a global Smarty variable to the global scope.

Parameters

string $varname

the global variable name

mixed $value

the value to assign

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assignByRef()

assignByRef(string  $tpl_var,   $value) : \Smarty_Internal_Data

Assigns values to template variables by reference

Parameters

string $tpl_var

the template variable name

$value

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

append()

append(array|string  $tpl_var, mixed  $value = null, boolean  $merge = false) : \Smarty_Internal_Data

Append an element to an assigned array

If you append to a string value, it is converted to an array value and then appended to. You can explicitly pass name/value pairs, or associative arrays containing the name/value pairs. If you pass the optional third parameter of true, the value will be merged with the current array instead of appended.

The $merge parameter does not use the PHP array_merge function. Merging two numerically indexed arrays may cause values to overwrite each other or result in non-sequential keys.

Parameters

array|string $tpl_var

the template variable name(s)

mixed $value

the value to append

boolean $merge

flag if array elements shall be merged

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

appendByRef()

appendByRef(string  $tpl_var,   $value, boolean  $merge = false) : \Smarty_Internal_Data

Appends values to template variables by reference

Parameters

string $tpl_var

the template variable name

$value
boolean $merge

flag if array elements shall be merged

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

getTemplateVars()

getTemplateVars(string  $varname = null, \Smarty_Internal_Data  $_ptr = null, boolean  $search_parents = true) : string|array

Returns a single or all assigned template variables

Parameters

string $varname

Name of variable to process, or null to return all

\Smarty_Internal_Data $_ptr

Optional reference to data object

boolean $search_parents

Whether to include results from parent scopes

Returns

string|array —

variable value or or array of variables

clearAssign()

clearAssign(string|array<mixed,string>  $tpl_var) : \Smarty_Internal_Data

Clear the given assigned template variable.

Parameters

string|array<mixed,string> $tpl_var

The template variable(s) to clear

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

clearAllAssign()

clearAllAssign() : \Smarty_Internal_Data

Clear all the assigned template variables.

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

configLoad()

configLoad(string  $config_file, string|array<mixed,string>|null  $sections = null) : \Smarty_Internal_Data

Load config file data and assign it to the template.

This works identically to the {config_load} function

Parameters

string $config_file

Path to the config file

string|array<mixed,string>|null $sections

Section name or array of section names

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

getVariable()

getVariable(string  $variable, \Smarty_Internal_Data|null  $_ptr = null, boolean  $search_parents = true, boolean  $error_enable = true) : mixed

Return the contents of an assigned variable.

Parameters

string $variable

the name of the Smarty variable

\Smarty_Internal_Data|null $_ptr

Optional reference to the data object

boolean $search_parents

Whether to search in the parent scope

boolean $error_enable

Whether to raise an error when the variable is not found.

Returns

mixed —

The contents of the variable.

getConfigVariable()

getConfigVariable(string  $variable,   $error_enable = true) : mixed

gets a config variable

Parameters

string $variable

the name of the config variable

$error_enable

Returns

mixed —

the value of the config variable

getStreamVariable()

getStreamVariable(string  $variable) : mixed

gets a stream variable

Parameters

string $variable

the stream of the variable

Returns

mixed —

the value of the stream variable

getConfigVars()

getConfigVars(string|null  $varname = null, boolean  $search_parents = true) : string

Returns a single or all config variables

Parameters

string|null $varname

Variable name or null (to retrieve all)

boolean $search_parents

Whether to search parent scopes

Returns

string —

variable value or or array of variables

clearConfig()

clearConfig(string|null  $varname = null) : \Smarty_Internal_Data

Clears all loaded config variables.

Parameters

string|null $varname

variable name or null

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

__construct()

__construct(string  $template_resource, \Smarty  $smarty, \Smarty_Internal_Template  $_parent = null, mixed  $_cache_id = null, mixed  $_compile_id = null, boolean  $_caching = null, integer  $_cache_lifetime = null) 

Create template data object

Some of the global Smarty settings copied to template scope It load the required template resources and cacher plugins

Parameters

string $template_resource

template resource string

\Smarty $smarty

Smarty instance

\Smarty_Internal_Template $_parent

back pointer to parent object with variables or null

mixed $_cache_id

cache id or null

mixed $_compile_id

compile id or null

boolean $_caching

use caching?

integer $_cache_lifetime

cache life-time in seconds

mustCompile()

mustCompile() : boolean

Returns if the current template must be compiled by the Smarty compiler

It does compare the timestamps of template source and the compiled templates and checks the force compile configuration

Returns

boolean —

true if the template must be compiled

compileTemplateSource()

compileTemplateSource() 

Compiles the template

If the template is not evaluated the compiled template is saved on disk

writeCachedContent()

writeCachedContent(  $content) : boolean

Writes the cached template output

Parameters

$content

Returns

boolean

getSubTemplate()

getSubTemplate(string  $template, mixed  $cache_id, mixed  $compile_id, integer  $caching, integer  $cache_lifetime,   $data, integer  $parent_scope) 

Template code runtime function to get subtemplate content

Parameters

string $template

the resource handle of the template file

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

integer $caching

cache mode

integer $cache_lifetime

life time of cache data

$data
integer $parent_scope

scope in which {include} should execute

setupInlineSubTemplate()

setupInlineSubTemplate(string  $template, mixed  $cache_id, mixed  $compile_id, integer  $caching, integer  $cache_lifetime,   $data, integer  $parent_scope) 

Template code runtime function to set up an inline subtemplate

Parameters

string $template

the resource handle of the template file

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

integer $caching

cache mode

integer $cache_lifetime

life time of cache data

$data
integer $parent_scope

scope in which {include} should execute

createTemplateCodeFrame()

createTemplateCodeFrame(string  $content = '', boolean  $cache = false) : string

Create code frame for compiled and cached templates

Parameters

string $content

optional template content

boolean $cache

flag for cache file

Returns

string

decodeProperties()

decodeProperties(array  $properties, boolean  $cache = false) : boolean

This function is executed automatically when a compiled or cached template file is included

  • Decode saved properties from compiled template and cache files
  • Check if compiled or cache file is valid

Parameters

array $properties

special template properties

boolean $cache

flag if called from cache file

Returns

boolean —

flag if compiled or cache file is valid

createLocalArrayVariable()

createLocalArrayVariable(string  $tpl_var, integer  $scope = \Smarty::SCOPE_LOCAL) 

Template code runtime function to create a local Smarty variable for array assignments

Parameters

string $tpl_var

tempate variable name

integer $scope

scope of variable

getScope()

getScope(integer  $scope) : array

Template code runtime function to get pointer to template variable array of requested scope

Parameters

integer $scope

requested variable scope

Returns

array —

array of template variables

getScopePointer()

getScopePointer(integer  $scope) : mixed

Get parent or root of template parent chain

Parameters

integer $scope

pqrent or root scope

Returns

mixed —

object

_count()

_count(mixed  $value) : integer

[util function] counts an array, arrayaccess/traversable or PDOStatement object

Parameters

mixed $value

Returns

integer —

the count for arrays and objects that implement countable, 1 for other objects that don't, and 0 for empty elements

capture_error()

capture_error() 

runtime error not matching capture tags

clearCache()

clearCache(integer  $exp_time = null) : integer

Empty cache for this template

Parameters

integer $exp_time

expiration time

Returns

integer —

number of cache files deleted

__set()

__set(string  $property_name, mixed  $value) 

set Smarty property in template context

Parameters

string $property_name

property name

mixed $value

value

__get()

__get(string  $property_name) 

get Smarty property in template context

Parameters

string $property_name

property name

__destruct()

__destruct() 

Template data object destrutor

replaceCamelcase()

replaceCamelcase(string  $match) : string

preg_replace callback to convert camelcase getter/setter to underscore property names

Parameters

string $match

match string

Returns

string —

replacemant