Smarty_Internal_Template
Main class with template data structures and methods
- Full name:
\Smarty_Internal_Template
- Parent class:
\Smarty_Internal_TemplateBase
Properties
tplObjCache
Template object cache
- This property is static.
isCacheTplObj
Template object cache for Smarty::isCached() === true
- This property is static.
subTplInfo
Sub template Info Cache - index name - value use count
- This property is static.
_objType
This object type (Smarty = 1, template = 2, data = 4)
smarty
Global smarty instance
source
Source instance
inheritance
Inheritance runtime extension
template_resource
Template resource
mustCompile
flag if compiled template is invalid and must be (re)compiled
templateId
Template Id
scope
Scope in which variables shall be assigned
isRenderingCache
Flag which is set while rending a cache file
startRenderCallbacks
Callbacks called before rendering template
endRenderCallbacks
Callbacks called after rendering template
Methods
__construct
Create template data object Some of the global Smarty settings copied to template scope It load the required template resources and caching plugins
public __construct(string $template_resource, \Smarty $smarty, null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent = null, mixed $_cache_id = null, mixed $_compile_id = null, bool|int|null $_caching = null, int|null $_cache_lifetime = null, bool $_isConfig = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$template_resource |
string | template resource string |
$smarty |
\Smarty | Smarty instance |
$_parent |
null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data | 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|int|null | use caching? |
$_cache_lifetime |
int|null | cache life-time in seconds |
$_isConfig |
bool |
Throws:
render
render template
Parameters:
Parameter | Type | Description |
---|---|---|
$no_output_filter |
bool | if true do not run output filter |
$display |
null|bool | true: display, false: fetch null: sub-template |
Throws:
_subTemplateRender
Runtime function to render sub-template
public _subTemplateRender(string $template, mixed $cache_id, mixed $compile_id, int $caching, int $cache_lifetime, array $data, int $scope, bool $forceTplCache, string $uid = null, string $content_func = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
string | template name |
$cache_id |
mixed | cache id |
$compile_id |
mixed | compile id |
$caching |
int | cache mode |
$cache_lifetime |
int | life time of cache data |
$data |
array | passed parameter template variables |
$scope |
int | scope in which {include} should execute |
$forceTplCache |
bool | cache template object |
$uid |
string | file dependency uid |
$content_func |
string | function name |
Throws:
_subTemplateRegister
Get called sub-templates and save call count
_isSubTpl
Check if this is a sub template
Return Value:
true is sub template
_assignInScope
Assign variable in scope
Parameters:
Parameter | Type | Description |
---|---|---|
$varName |
string | variable name |
$value |
mixed | value |
$nocache |
bool | nocache flag |
$scope |
int | scope into which variable shall be assigned |
_checkPlugins
Check if plugins are callable require file otherwise
Parameters:
Parameter | Type | Description |
---|---|---|
$plugins |
array | required plugins |
Throws:
_decodeProperties
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
public _decodeProperties(\Smarty_Internal_Template $tpl, array $properties, bool $cache = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tpl |
\Smarty_Internal_Template | |
$properties |
array | special template properties |
$cache |
bool | flag if called from cache file |
Return Value:
flag if compiled or cache file is valid
Throws:
compileTemplateSource
Compiles the template If the template is not evaluated the compiled template is saved on disk
Throws:
writeCachedContent
Writes the content to cache resource
Parameters:
Parameter | Type | Description |
---|---|---|
$content |
string |
_getTemplateId
Get unique template id
Throws:
capture_error
runtime error not matching capture tags
Throws:
loadCompiled
Load compiled object
Parameters:
Parameter | Type | Description |
---|---|---|
$force |
bool | force new compiled object |
loadCached
Load cached object
Parameters:
Parameter | Type | Description |
---|---|---|
$force |
bool | force new cached object |
_loadInheritance
Load inheritance object
_cleanUp
Unload inheritance object
loadCompiler
Load compiler object
Throws:
__call
Handle unknown class methods
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | unknown method-name |
$args |
array | argument array |
__get
get Smarty property in template context
Parameters:
Parameter | Type | Description |
---|---|---|
$property_name |
string | property name |
Throws:
__set
set Smarty property in template context
Parameters:
Parameter | Type | Description |
---|---|---|
$property_name |
string | property name |
$value |
mixed | value |
Throws:
__destruct
Template data object destructor
Inherited methods
__construct
Smarty_Internal_Data constructor.
Install extension handler
assign
assigns a Smarty variable
public assign(array|string $tpl_var, mixed $value = null, bool $nocache = false): \Smarty_Internal_Data
Parameters:
Parameter | Type | Description |
---|---|---|
$tpl_var |
array|string | the template variable name(s) |
$value |
mixed | the value to assign |
$nocache |
bool | if true any output of this variable will be not cached |
Return Value:
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
append
appends values to template variables
public append(array|string $tpl_var, mixed $value = null, bool $merge = false, bool $nocache = false): \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
Parameters:
Parameter | Type | Description |
---|---|---|
$tpl_var |
array|string | the template variable name(s) |
$value |
mixed | the value to append |
$merge |
bool | flag if array elements shall be merged |
$nocache |
bool | if true any output of this variable will be not cached |
See Also:
- https://www.smarty.net/docs/en/api.append.tpl -
assignGlobal
assigns a global Smarty variable
public assignGlobal(string $varName, mixed $value = null, bool $nocache = false): \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
Parameters:
Parameter | Type | Description |
---|---|---|
$varName |
string | the global variable name |
$value |
mixed | the value to assign |
$nocache |
bool | if true any output of this variable will be not cached |
appendByRef
appends values to template variables by reference
public appendByRef(string $tpl_var, mixed& $value, bool $merge = false): \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
Parameters:
Parameter | Type | Description |
---|---|---|
$tpl_var |
string | the template variable name |
$value |
mixed | the referenced value to append |
$merge |
bool | flag if array elements shall be merged |
assignByRef
assigns values to template variables by reference
public assignByRef(string $tpl_var, mixed& $value, bool $nocache = false): \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
Parameters:
Parameter | Type | Description |
---|---|---|
$tpl_var |
string | the template variable name |
$value |
mixed | |
$nocache |
bool | if true any output of this variable will be not cached |
getTemplateVars
Returns a single or all template variables
public getTemplateVars(string $varName = null, \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr = null, bool $searchParents = true): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$varName |
string | variable name or null |
$_ptr |
\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty | optional pointer to data object |
$searchParents |
bool | include parent templates? |
Return Value:
variable value or or array of variables
See Also:
- https://www.smarty.net/docs/en/api.get.template.vars.tpl -
_mergeVars
Follow the parent chain an merge template and config variables
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
\Smarty_Internal_Data|null |
_isDataObj
Return true if this instance is a Data obj
_isTplObj
Return true if this instance is a template obj
_isSmartyObj
Return true if this instance is a Smarty obj
_getSmartyObj
Get Smarty object
__call
Handle unknown class methods
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | unknown method-name |
$args |
array | argument array |
fetch
fetches a rendered Smarty template
public fetch(string $template = null, mixed $cache_id = null, mixed $compile_id = null, object $parent = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$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 |
Return Value:
rendered template output
Throws:
display
displays a Smarty template
public display(string $template = null, mixed $cache_id = null, mixed $compile_id = null, object $parent = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$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 |
Throws:
isCached
test if cache is valid
public isCached(null|string|\Smarty_Internal_Template $template = null, mixed $cache_id = null, mixed $compile_id = null, object $parent = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
null|string|\Smarty_Internal_Template | 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 |
Return Value:
cache status
Throws:
See Also:
- https://www.smarty.net/docs/en/api.is.cached.tpl -
_execute
fetches a rendered Smarty template
private _execute(string $template, mixed $cache_id, mixed $compile_id, object $parent, string $function): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$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 |
$function |
string | function type 0 = fetch, 1 = display, 2 = isCache |
Throws:
registerPlugin
Registers plugin to be used in templates
public registerPlugin(string $type, string $name, callable $callback, bool $cacheable = true, mixed $cache_attr = null): \Smarty|\Smarty_Internal_Template
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
string | plugin type |
$name |
string | name of template tag |
$callback |
callable | PHP callback to register |
$cacheable |
bool | if true (default) this function is cache able |
$cache_attr |
mixed | caching attributes if any |
Throws:
See Also:
- https://www.smarty.net/docs/en/api.register.plugin.tpl -
loadFilter
load a filter of specified type and name
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
string | filter type |
$name |
string | filter name |
Throws:
See Also:
- https://www.smarty.net/docs/en/api.load.filter.tpl -
registerFilter
Registers a filter function
public registerFilter(string $type, callable $callback, string|null $name = null): \Smarty|\Smarty_Internal_Template
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
string | filter type |
$callback |
callable | |
$name |
string|null | optional filter name |
Throws:
See Also:
- https://www.smarty.net/docs/en/api.register.filter.tpl -
registerObject
Registers object to be used in templates
public registerObject(string $object_name, object $object, array $allowed_methods_properties = array(), bool $format = true, array $block_methods = array()): \Smarty|\Smarty_Internal_Template
Parameters:
Parameter | Type | Description |
---|---|---|
$object_name |
string | |
$object |
object | the referenced PHP object to register |
$allowed_methods_properties |
array | list of allowed methods (empty = all) |
$format |
bool | smarty argument format, else traditional |
$block_methods |
array | list of block-methods |
Throws:
See Also:
- https://www.smarty.net/docs/en/api.register.object.tpl -
setCompileCheck
Parameters:
Parameter | Type | Description |
---|---|---|
$compile_check |
int |
setCaching
Parameters:
Parameter | Type | Description |
---|---|---|
$caching |
int |
setCacheLifetime
Parameters:
Parameter | Type | Description |
---|---|---|
$cache_lifetime |
int |
setCompileId
Parameters:
Parameter | Type | Description |
---|---|---|
$compile_id |
string |
setCacheId
Parameters:
Parameter | Type | Description |
---|---|---|
$cache_id |
string |
Automatically generated on 2025-03-18