Properties

$template_class

$template_class : string

name of class used for templates

Type

string

$tpl_vars

$tpl_vars : array

template variables

Type

array

$config_vars

$config_vars : array

configuration settings

Type

array

$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

$has_nocache_code

$has_nocache_code : boolean

flag if template does contain nocache code sections

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

fetches a rendered Smarty template

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) 

displays a Smarty template

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, object  $parent = null) : boolean

test if cache is valid

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

object $parent

next higher level of Smarty variables

Returns

boolean —

cache status

createData()

createData(object  $parent = null) 

creates a data object

Parameters

object $parent

next higher level of Smarty variables

registerPlugin()

registerPlugin(string  $type, string  $tag, callback  $callback, boolean  $cacheable = true, array  $cache_attr = null) 

Registers plugin to be used in templates

Parameters

string $type

plugin type

string $tag

name of template tag

callback $callback

PHP callback to register

boolean $cacheable

if true (default) this fuction is cachable

array $cache_attr

caching attributes if any

Throws

\SmartyException

when the plugin tag is invalid

unregisterPlugin()

unregisterPlugin(string  $type, string  $tag) 

Unregister Plugin

Parameters

string $type

of plugin

string $tag

name of plugin

registerResource()

registerResource(string  $type, \Smarty_Resource|array  $callback) 

Registers a resource to fetch a template

Parameters

string $type

name of resource type

\Smarty_Resource|array $callback

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

unregisterResource()

unregisterResource(string  $type) 

Unregisters a resource

Parameters

string $type

name of resource type

registerCacheResource()

registerCacheResource(string  $type, \Smarty_CacheResource  $callback) 

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

unregisterCacheResource()

unregisterCacheResource(string  $type) 

Unregisters a cache resource

Parameters

string $type

name of cache resource type

registerObject()

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

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

getRegisteredObject()

getRegisteredObject(string  $name) : object

return a reference to a registered object

Parameters

string $name

object name

Throws

\SmartyException

if no such object is found

Returns

object

unregisterObject()

unregisterObject(string  $name) 

unregister an object

Parameters

string $name

object name

Throws

\SmartyException

if no such object is found

registerClass()

registerClass(  $class_name, string  $class_impl) 

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

registerDefaultPluginHandler()

registerDefaultPluginHandler(callable  $callback) 

Registers a default plugin handler

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

registerDefaultTemplateHandler()

registerDefaultTemplateHandler(callable  $callback) 

Registers a default template handler

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

registerDefaultConfigHandler()

registerDefaultConfigHandler(callable  $callback) 

Registers a default template handler

Parameters

callable $callback

class/method name

Throws

\SmartyException

if $callback is not callable

registerFilter()

registerFilter(string  $type, callback  $callback) 

Registers a filter function

Parameters

string $type

filter type

callback $callback

unregisterFilter()

unregisterFilter(string  $type, callback  $callback) 

Unregisters a filter function

Parameters

string $type

filter type

callback $callback

_get_filter_name()

_get_filter_name(callback  $function_name) 

Return internal filter name

Parameters

callback $function_name

loadFilter()

loadFilter(string  $type, string  $name) : boolean

load a filter of specified type and name

Parameters

string $type

filter type

string $name

filter name

Returns

boolean

unloadFilter()

unloadFilter(string  $type, string  $name) : boolean

unload a filter of specified type and name

Parameters

string $type

filter type

string $name

filter name

Returns

boolean

__call()

__call(string  $name, array  $args) 

Handle unknown class methods

Parameters

string $name

unknown method-name

array $args

argument array

assign()

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

assigns a Smarty variable

Parameters

array|string $tpl_var

the template variable name(s)

mixed $value

the value to assign

boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assignGlobal()

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

assigns a global Smarty variable

Parameters

string $varname

the global variable name

mixed $value

the value to assign

boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assignByRef()

assignByRef(string  $tpl_var,   $value, boolean  $nocache = false) : \Smarty_Internal_Data

assigns values to template variables by reference

Parameters

string $tpl_var

the template variable name

$value
boolean $nocache

if true any output of this variable will be not cached

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, boolean  $nocache = false) : \Smarty_Internal_Data

appends values to template variables

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

boolean $nocache

if true any output of this variable will be not cached

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, string  $_ptr = null, boolean  $search_parents = true) : string

Returns a single or all template variables

Parameters

string $varname

variable name or null

string $_ptr

optional pointer to data object

boolean $search_parents

include parent templates?

Returns

string —

variable value or or array of variables

clearAssign()

clearAssign(string|array  $tpl_var) : \Smarty_Internal_Data

clear the given assigned template variable.

Parameters

string|array $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, mixed  $sections = null) : \Smarty_Internal_Data

load a config file, optionally load just selected sections

Parameters

string $config_file

filename

mixed $sections

array of section names, single section or null

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

getVariable()

getVariable(string  $variable, object  $_ptr = null, boolean  $search_parents = true,   $error_enable = true) : object

gets the object of a Smarty variable

Parameters

string $variable

the name of the Smarty variable

object $_ptr

optional pointer to data object

boolean $search_parents

search also in parent data

$error_enable

Returns

object —

the object 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  $varname = null,   $search_parents = true) : string

Returns a single or all config variables

Parameters

string $varname

variable name or null

$search_parents

Returns

string —

variable value or or array of variables

clearConfig()

clearConfig(string  $varname = null) : \Smarty_Internal_Data

Deassigns a single or all config variables

Parameters

string $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, string  $hash) 

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

string $hash

nocache hash code

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, boolean  $nocache = false, 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

boolean $nocache

cache mode of variable

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