Methods

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

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

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