| Recommend this page to a friend! |
| Packages of Michael Beck | Xoops 2.5 | htdocs/xoops_lib/vendor/smarty/smarty/docs/designers/language-builtin-functions/language-function-assign.md | Download |
|
|||||||||||||||||||||
{assign}, {$var=...}
Attributes of the {assign} syntax| Attribute Name | Required | Description | |----------------|------------|-----------------------------------------------------------------------| | var | | The name of the variable being assigned | | value | | The value being assigned | | scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' | Attributes of the {$var=...} syntax| Attribute Name | Required | Description | |----------------|------------|-----------------------------------------------------------------------| | scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' | Option Flags| Name | Description | |---------|---------------------------------------------------| | nocache | Assigns the variable with the 'nocache' attribute | > Note > > Assignment of variables in-template is essentially placing application > logic into the presentation that may be better handled in PHP. Use at > your own discretion. Examples
The above example will output:
The above example will output:
Variables assigned in the included template will be seen in the including template.
The template above includes the example
You can assign a variable to root of the current root tree. The variable is seen by all templates using the same root tree. A global variable is seen by all templates.
To access
The template variables are only available after/during template execution as in the following script.
The following functions can also optionally assign template variables: See also |