\Smarty_Data

class for the Smarty data object

The Smarty data object will hold Smarty variables in the current scope

Summary

Methods
Properties
Constants
assign()
assignGlobal()
assignByRef()
append()
appendByRef()
getTemplateVars()
clearAssign()
clearAllAssign()
configLoad()
getVariable()
getConfigVariable()
getStreamVariable()
getConfigVars()
clearConfig()
__construct()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

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

__construct()

__construct(\Smarty|array  $_parent = null, \Smarty  $smarty = null) 

Create Smarty data object

Parameters

\Smarty|array $_parent

parent template

\Smarty $smarty

global smarty instance