Main class with template data structures and methods

package Smarty
subpackage Template

 Methods

Handle unknown class methods

__call(string $name, array $args) 
Inherited
inherited_from \Smarty_Internal_TemplateBase::__call()

Parameters

$name

string

unknown method-name

$args

array

argument array

Create template data object

__construct(string $template_resource, \Smarty $smarty, \Smarty_Internal_Template $_parent, mixed $_cache_id, mixed $_compile_id, bool $_caching, int $_cache_lifetime) 

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

Parameters

$template_resource

string

template resource string

$smarty

\Smarty

Smarty instance

$_parent

\Smarty_Internal_Template

back pointer to parent object with variables or null

$_cache_id

mixed

cache id or null

$_compile_id

mixed

compile id or null

$_caching

bool

use caching?

$_cache_lifetime

int

cache life-time in seconds

Template data object destrutor

__destruct() 

get Smarty property in template context

__get(string $property_name) 

Parameters

$property_name

string

property name

set Smarty property in template context

__set(string $property_name, mixed $value) 

Parameters

$property_name

string

property name

$value

mixed

value

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

_count(mixed $value) : int

Parameters

$value

mixed

Returns

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

Return internal filter name

_get_filter_name(callback $function_name) : string
Inherited
inherited_from \Smarty_Internal_TemplateBase::_get_filter_name()

Parameters

$function_name

callback

Returns

stringinternal filter name

appends values to template variables

append(array | string $tpl_var, mixed $value, boolean $merge, boolean $nocache) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::append()
inherited_from \Smarty_Internal_TemplateBase::append()

Parameters

$tpl_var

arraystring

the template variable name(s)

$value

mixed

the value to append

$merge

boolean

flag if array elements shall be merged

$nocache

boolean

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

appends values to template variables by reference

appendByRef(string $tpl_var, mixed $value, boolean $merge) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::appendByRef()
inherited_from \Smarty_Internal_TemplateBase::appendByRef()

Parameters

$tpl_var

string

the template variable name

$value

mixed

&$value the referenced value to append

$merge

boolean

flag if array elements shall be merged

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assigns a Smarty variable

assign(array | string $tpl_var, mixed $value, boolean $nocache) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::assign()
inherited_from \Smarty_Internal_TemplateBase::assign()

Parameters

$tpl_var

arraystring

the template variable name(s)

$value

mixed

the value to assign

$nocache

boolean

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assigns values to template variables by reference

assignByRef(string $tpl_var, $value, boolean $nocache) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::assignByRef()
inherited_from \Smarty_Internal_TemplateBase::assignByRef()

Parameters

$tpl_var

string

the template variable name

$value

$nocache

boolean

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

assigns a global Smarty variable

assignGlobal(string $varname, mixed $value, boolean $nocache) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::assignGlobal()
inherited_from \Smarty_Internal_TemplateBase::assignGlobal()

Parameters

$varname

string

the global variable name

$value

mixed

the value to assign

$nocache

boolean

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

runtime error not matching capture tags

capture_error() 

clear all the assigned template variables.

clearAllAssign() : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::clearAllAssign()
inherited_from \Smarty_Internal_TemplateBase::clearAllAssign()

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

clear the given assigned template variable.

clearAssign(string | array $tpl_var) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::clearAssign()
inherited_from \Smarty_Internal_TemplateBase::clearAssign()

Parameters

$tpl_var

stringarray

the template variable(s) to clear

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

Empty cache for this template

clearCache(integer $exp_time) : integer

Parameters

$exp_time

integer

expiration time

Returns

integernumber of cache files deleted

Deassigns a single or all config variables

clearConfig(string $varname) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::clearConfig()
inherited_from \Smarty_Internal_TemplateBase::clearConfig()

Parameters

$varname

string

variable name or null

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

Compiles the template

compileTemplateSource() 

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

load a config file, optionally load just selected sections

configLoad(string $config_file, mixed $sections) : \Smarty_Internal_Data
Inherited
inherited_from \Smarty_Internal_Data::configLoad()
inherited_from \Smarty_Internal_TemplateBase::configLoad()

Parameters

$config_file

string

filename

$sections

mixed

array of section names, single section or null

Returns

\Smarty_Internal_Datacurrent Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

creates a data object

createData(object $parent) 
Inherited
returns Smarty_Data data object
inherited_from \Smarty_Internal_TemplateBase::createData()

Parameters

$parent

object

next higher level of Smarty variables

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

createLocalArrayVariable(string $tpl_var, bool $nocache, int $scope) 

Parameters

$tpl_var

string

tempate variable name

$nocache

bool

cache mode of variable

$scope

int

scope of variable

Create code frame for compiled and cached templates

createTemplateCodeFrame(string $content, bool $cache) : string

Parameters

$content

string

optional template content

$cache

bool

flag for cache file

Returns

string

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

decodeProperties(array $properties, bool $cache) : bool
  • Decode saved properties from compiled template and cache files
  • Check if compiled or cache file is valid

Parameters

$properties

array

special template properties

$cache

bool

flag if called from cache file

Returns

boolflag if compiled or cache file is valid

displays a Smarty template

display(string $template, mixed $cache_id, mixed $compile_id, object $parent) 
Inherited
inherited_from \Smarty_Internal_TemplateBase::display()

Parameters

$template

string

the resource handle of the template file or template object

$cache_id

mixed

cache id to be used with this template

$compile_id

mixed

compile id to be used with this template

$parent

object

next higher level of Smarty variables

fetches a rendered Smarty template

fetch(string $template, mixed $cache_id, mixed $compile_id, object $parent, bool $display, bool $merge_tpl_vars, bool $no_output_filter) : string
Inherited
inherited_from \Smarty_Internal_TemplateBase::fetch()

Parameters

$template

string

the resource handle of the template file or template object

$cache_id

mixed

cache id to be used with this template

$compile_id

mixed

compile id to be used with this template

$parent

object

next higher level of Smarty variables

$display

bool

true: display, false: fetch

$merge_tpl_vars

bool

if true parent template variables merged in to local scope

$no_output_filter

bool

if true do not run output filter

Returns

stringrendered template output

gets a config variable

getConfigVariable(string $variable, $error_enable) : mixed
Inherited
inherited_from \Smarty_Internal_Data::getConfigVariable()
inherited_from \Smarty_Internal_TemplateBase::getConfigVariable()

Parameters

$variable

string

the name of the config variable

$error_enable

Returns

mixedthe value of the config variable

Returns a single or all config variables

getConfigVars(string $varname, $search_parents) : string
Inherited
inherited_from \Smarty_Internal_Data::getConfigVars()
inherited_from \Smarty_Internal_TemplateBase::getConfigVars()

Parameters

$varname

string

variable name or null

$search_parents

Returns

stringvariable value or or array of variables

return a reference to a registered object

getRegisteredObject(string $name) : object
Inherited
inherited_from \Smarty_Internal_TemplateBase::getRegisteredObject()

Parameters

$name

string

object name

Exceptions

\SmartyException if no such object is found

Returns

object

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

getScope(int $scope) : array

Parameters

$scope

int

requested variable scope

Returns

arrayarray of template variables

Get parent or root of template parent chain

getScopePointer(int $scope) : mixed

Parameters

$scope

int

pqrent or root scope

Returns

mixedobject

gets a stream variable

getStreamVariable(string $variable) : mixed
Inherited
inherited_from \Smarty_Internal_Data::getStreamVariable()
inherited_from \Smarty_Internal_TemplateBase::getStreamVariable()

Parameters

$variable

string

the stream of the variable

Returns

mixedthe value of the stream variable

Template code runtime function to get subtemplate content

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

Parameters

$template

string

the resource handle of the template file

$cache_id

mixed

cache id to be used with this template

$compile_id

mixed

compile id to be used with this template

$caching

integer

cache mode

$cache_lifetime

integer

life time of cache data

$data

$parent_scope

int

scope in which {include} should execute

Returns a single or all template variables

getTemplateVars(string $varname, string $_ptr, boolean $search_parents) : string
Inherited
inherited_from \Smarty_Internal_Data::getTemplateVars()
inherited_from \Smarty_Internal_TemplateBase::getTemplateVars()

Parameters

$varname

string

variable name or null

$_ptr

string

optional pointer to data object

$search_parents

boolean

include parent templates?

Returns

stringvariable value or or array of variables

gets the object of a Smarty variable

getVariable(string $variable, object $_ptr, boolean $search_parents, $error_enable) : object
Inherited
inherited_from \Smarty_Internal_Data::getVariable()
inherited_from \Smarty_Internal_TemplateBase::getVariable()

Parameters

$variable

string

the name of the Smarty variable

$_ptr

object

optional pointer to data object

$search_parents

boolean

search also in parent data

$error_enable

Returns

objectthe object of the variable

test if cache is valid

isCached(string | object $template, mixed $cache_id, mixed $compile_id, object $parent) : boolean
Inherited
inherited_from \Smarty_Internal_TemplateBase::isCached()

Parameters

$template

stringobject

the resource handle of the template file or template object

$cache_id

mixed

cache id to be used with this template

$compile_id

mixed

compile id to be used with this template

$parent

object

next higher level of Smarty variables

Returns

booleancache status

load a filter of specified type and name

loadFilter(string $type, string $name) 
Inherited
inherited_from \Smarty_Internal_TemplateBase::loadFilter()

Parameters

$type

string

filter type

$name

string

filter name

Exceptions

\SmartyException if filter could not be loaded

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

mustCompile() : boolean

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

Returns

booleantrue if the template must be compiled

Registers a cache resource to cache a template's output

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

Parameters

$type

string

name of cache resource type

$callback

\Smarty_CacheResource

instance of Smarty_CacheResource to handle output caching

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers static classes to be used in templates

registerClass($class_name, string $class_impl) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerClass()

Parameters

$class_name

$class_impl

string

the referenced PHP class to register

Exceptions

\SmartyException if $class_impl does not refer to an existing class

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers a default template handler

registerDefaultConfigHandler(callable $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerDefaultConfigHandler()

Parameters

$callback

callable

class/method name

Exceptions

\SmartyException if $callback is not callable

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers a default plugin handler

registerDefaultPluginHandler(callable $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerDefaultPluginHandler()

Parameters

$callback

callable

class/method name

Exceptions

\SmartyException if $callback is not callable

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers a default template handler

registerDefaultTemplateHandler(callable $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerDefaultTemplateHandler()

Parameters

$callback

callable

class/method name

Exceptions

\SmartyException if $callback is not callable

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers a filter function

registerFilter(string $type, callback $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerFilter()

Parameters

$type

string

filter type

$callback

callback

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers object to be used in templates

registerObject($object_name, object $object_impl, array $allowed, boolean $smarty_args, array $block_methods) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerObject()

Parameters

$object_name

$object_impl

object

the referenced PHP object to register

$allowed

array

list of allowed methods (empty = all)

$smarty_args

boolean

smarty argument format, else traditional

$block_methods

array

list of block-methods

Exceptions

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

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers plugin to be used in templates

registerPlugin(string $type, string $tag, callback $callback, boolean $cacheable, array $cache_attr) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerPlugin()

Parameters

$type

string

plugin type

$tag

string

name of template tag

$callback

callback

PHP callback to register

$cacheable

boolean

if true (default) this fuction is cachable

$cache_attr

array

caching attributes if any

Exceptions

\SmartyException when the plugin tag is invalid

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Registers a resource to fetch a template

registerResource(string $type, \Smarty_Resource | array $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::registerResource()

Parameters

$type

string

name of resource type

$callback

\Smarty_Resourcearray

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

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Template code runtime function to set up an inline subtemplate

setupInlineSubTemplate(string $template, mixed $cache_id, mixed $compile_id, integer $caching, integer $cache_lifetime, $data, int $parent_scope, string $hash) 
returns string template content

Parameters

$template

string

the resource handle of the template file

$cache_id

mixed

cache id to be used with this template

$compile_id

mixed

compile id to be used with this template

$caching

integer

cache mode

$cache_lifetime

integer

life time of cache data

$data

$parent_scope

int

scope in which {include} should execute

$hash

string

nocache hash code

unload a filter of specified type and name

unloadFilter(string $type, string $name) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unloadFilter()

Parameters

$type

string

filter type

$name

string

filter name

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Unregisters a cache resource

unregisterCacheResource(string $type) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unregisterCacheResource()

Parameters

$type

string

name of cache resource type

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Unregisters a filter function

unregisterFilter(string $type, callback $callback) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unregisterFilter()

Parameters

$type

string

filter type

$callback

callback

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

unregister an object

unregisterObject(string $name) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unregisterObject()

Parameters

$name

string

object name

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Unregister Plugin

unregisterPlugin(string $type, string $tag) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unregisterPlugin()

Parameters

$type

string

of plugin

$tag

string

name of plugin

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Unregisters a resource

unregisterResource(string $type) : \Smarty_Internal_Templatebase
Inherited
inherited_from \Smarty_Internal_TemplateBase::unregisterResource()

Parameters

$type

string

name of resource type

Returns

\Smarty_Internal_Templatebasecurrent Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining

Writes the cached template output

writeCachedContent($content) : bool

Parameters

$content

Returns

bool

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

replaceCamelcase(string $match) : string
Inherited
inherited_from \Smarty_Internal_TemplateBase::replaceCamelcase()

Parameters

$match

string

match string

Returns

stringreplacemant

 Properties

 

$_capture_stack : array
 

$allow_relative_path : bool
 

$block_data : array
 

$cache_id : string
 

$cache_lifetime : integer
 

$cached : \Smarty_Template_Cached
magic
property
 

$caching : boolean
 

$compile_id : string
 

$compiled : \Smarty_Template_Compiled
magic
property
 

$config_vars : array
Inherited
inherited_from \Smarty_Internal_Data::$$config_vars
inherited_from \Smarty_Internal_TemplateBase::$$config_vars
 

$has_nocache_code : bool
 

$mustCompile : bool
 

$parent : \Smarty_Internal_Template
Inherited
inherited_from \Smarty_Internal_Data::$$parent
inherited_from \Smarty_Internal_TemplateBase::$$parent
 

$properties : array
 

$required_plugins : array
 

$smarty : \Smarty
 

$source : \Smarty_Template_Source
magic
property
 

$template_class : string
Inherited
inherited_from \Smarty_Internal_Data::$$template_class
inherited_from \Smarty_Internal_TemplateBase::$$template_class
 

$template_resource : string
 

$tpl_vars : array
Inherited
inherited_from \Smarty_Internal_Data::$$tpl_vars
inherited_from \Smarty_Internal_TemplateBase::$$tpl_vars
 

$used_tags : array
 

$variable_filters : array