$cache_id
$cache_id : string
cache_id
Main class with template data structures and methods
$smarty : \Smarty
Global smarty instance
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.
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 |
rendered template output
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.
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(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.
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 |
The template's cache status
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.
object|null | $parent | Optional link to a parent scope |
data object
None found |
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
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 |
when the plugin tag is invalid
Self-reference to facilitate chaining
None found |
unregisterPlugin(string $type, string $tag) : \Smarty_Internal_TemplateBase
Unregister Plugin
string | $type | of plugin |
string | $tag | name of plugin |
Self-reference to facilitate chaining
None found |
registerResource(string $type, \Smarty_Resource|array<mixed,\Smarty_Resource> $callback) : \Smarty_Internal_TemplateBase
Registers a resource to fetch a template
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) |
Self-reference to facilitate chaining
None found |
unregisterResource(string $type) : \Smarty_Internal_TemplateBase
Unregisters a resource
string | $type | name of resource type |
Self-reference to facilitate chaining
None found |
registerCacheResource(string $type, \Smarty_CacheResource $callback) : \Smarty_Internal_TemplateBase
Registers a cache resource to cache a template's output
string | $type | Name of cache resource type |
\Smarty_CacheResource | $callback | instance of Smarty_CacheResource to handle output caching |
Self-reference to facilitate chaining
None found |
unregisterCacheResource(string $type) : \Smarty_Internal_TemplateBase
Unregisters a cache resource
string | $type | name of cache resource type |
Self-reference to facilitate chaining
None found |
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
$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 |
if any of the methods in $allowed or $block_methods are invalid
Self-reference to facilitate chaining
None found |
getRegisteredObject(string $name) : mixed
Returns a reference to a registered object.
string | $name | object name |
if no such object is found
None found |
unregisterObject(string $name) : \Smarty_Internal_TemplateBase
unregister an object
string | $name | object name |
Self-reference to facilitate chaining
None found |
registerClass( $class_name, string $class_impl) : \Smarty_Internal_TemplateBase
Registers static classes to be used in templates
$class_name | ||
string | $class_impl | the referenced PHP class to register |
if $class_impl does not refer to an existing class
Self-reference to facilitate chaining
None found |
registerDefaultPluginHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default plugin handler
A default plugin handler gets called on undefined tags.
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerDefaultTemplateHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default template handler
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerDefaultConfigHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default template handler
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerFilter(string $type, callback $callback) : \Smarty_Internal_TemplateBase
Registers a filter function
string | $type | filter type |
callback | $callback |
Self-reference to facilitate chaining
None found |
unregisterFilter(string $type, callback $callback) : \Smarty_Internal_TemplateBase
Unregisters a filter function
string | $type | filter type |
callback | $callback |
Self-reference to facilitate chaining
None found |
loadFilter(string $type, string $name)
Load a filter of specified type and name
string | $type | filter type |
string | $name | filter name |
if filter could not be loaded
None found |
unloadFilter(string $type, string $name) : \Smarty_Internal_TemplateBase
unload a filter of specified type and name
string | $type | filter type |
string | $name | filter name |
Self-reference to facilitate chaining
None found |
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.
array|string | $var | the template variable name(s) |
mixed | $value | the value to assign |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
assignGlobal(string $varname, mixed $value = null) : \Smarty_Internal_Data
Assigns a global Smarty variable to the global scope.
string | $varname | the global variable name |
mixed | $value | the value to assign |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
todo |
This may not work with multiple Brainy instances. |
---|
assignByRef(string $tpl_var, $value) : \Smarty_Internal_Data
Assigns values to template variables by reference
string | $tpl_var | the template variable name |
$value |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
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.
array|string | $tpl_var | the template variable name(s) |
mixed | $value | the value to append |
boolean | $merge | flag if array elements shall be merged |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
appendByRef(string $tpl_var, $value, boolean $merge = false) : \Smarty_Internal_Data
Appends values to template variables by reference
string | $tpl_var | the template variable name |
$value | ||
boolean | $merge | flag if array elements shall be merged |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
getTemplateVars(string $varname = null, \Smarty_Internal_Data $_ptr = null, boolean $search_parents = true) : string|array
Returns a single or all assigned template variables
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 |
variable value or or array of variables
None found |
clearAssign(string|array<mixed,string> $tpl_var) : \Smarty_Internal_Data
Clear the given assigned template variable.
string|array<mixed,string> | $tpl_var | The template variable(s) to clear |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
clearAllAssign() : \Smarty_Internal_Data
Clear all the assigned template variables.
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
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
string | $config_file | Path to the config file |
string|array<mixed,string>|null | $sections | Section name or array of section names |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
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.
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. |
The contents of the variable.
None found |
getConfigVariable(string $variable, $error_enable = true) : mixed
gets a config variable
string | $variable | the name of the config variable |
$error_enable |
the value of the config variable
None found |
getStreamVariable(string $variable) : mixed
gets a stream variable
string | $variable | the stream of the variable |
the value of the stream variable
None found |
getConfigVars(string|null $varname = null, boolean $search_parents = true) : string
Returns a single or all config variables
string|null | $varname | Variable name or null (to retrieve all) |
boolean | $search_parents | Whether to search parent scopes |
variable value or or array of variables
None found |
clearConfig(string|null $varname = null) : \Smarty_Internal_Data
Clears all loaded config variables.
string|null | $varname | variable name or null |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
__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
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 |
None found |
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
true if the template must be compiled
None found |
compileTemplateSource()
Compiles the template
If the template is not evaluated the compiled template is saved on disk
None found |
writeCachedContent( $content) : boolean
Writes the cached template output
$content |
None found |
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
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 |
returns |
string template content |
---|
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
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 |
returns |
string template content |
---|
createTemplateCodeFrame(string $content = '', boolean $cache = false) : string
Create code frame for compiled and cached templates
string | $content | optional template content |
boolean | $cache | flag for cache file |
None found |
decodeProperties(array $properties, boolean $cache = false) : boolean
This function is executed automatically when a compiled or cached template file is included
array | $properties | special template properties |
boolean | $cache | flag if called from cache file |
flag if compiled or cache file is valid
None found |
createLocalArrayVariable(string $tpl_var, integer $scope = \Smarty::SCOPE_LOCAL)
Template code runtime function to create a local Smarty variable for array assignments
string | $tpl_var | tempate variable name |
integer | $scope | scope of variable |
None found |
getScope(integer $scope) : array
Template code runtime function to get pointer to template variable array of requested scope
integer | $scope | requested variable scope |
array of template variables
None found |
getScopePointer(integer $scope) : mixed
Get parent or root of template parent chain
integer | $scope | pqrent or root scope |
object
None found |
_count(mixed $value) : integer
[util function] counts an array, arrayaccess/traversable or PDOStatement object
mixed | $value |
the count for arrays and objects that implement countable, 1 for other objects that don't, and 0 for empty elements
None found |
clearCache(integer $exp_time = null) : integer
Empty cache for this template
integer | $exp_time | expiration time |
number of cache files deleted
None found |
__set(string $property_name, mixed $value)
set Smarty property in template context
string | $property_name | property name |
mixed | $value | value |
None found |
__get(string $property_name)
get Smarty property in template context
string | $property_name | property name |
None found |
replaceCamelcase(string $match) : string
preg_replace callback to convert camelcase getter/setter to underscore property names
string | $match | match string |
replacemant
None found |