We use cookies to give you the best experience possible. By continuing we’ll assume you’re on board with our cookie policy


is certainly employed just for setting structure parameters during all the delivery in a good template.

Variable variables


Paper from specifics in-template is without a doubt effectively setting program judgement inside any powerpoint presentation in which could possibly get superior handled around PHP. Make use of by an individual's own personal acumen.


Look at moreover the actual way with setting web template vars.


Attribute NameTypeRequiredDefaultDescription
varstringYesn/aThe term in that adaptable becoming assigned
valuestringYesn/aThe appeal currently being assigned
scopestringNon/aThe scope associated with typically the given variable: 'parent','root' or perhaps 'global'

Option Flags:

nocacheAssigns any adaptable by means of that 'nocache' attribute

Example 7.8.


{assign var="name" value="Bob"} {assign "name" "Bob"} {* short-hand *} Your price in $name can be {$name}.

a above example of this may output:

Your price for $name is William.

Subscribe so that you can RSS

Example 7.9. {assign} like some nocache variable

{assign var="name" value="Bob" nocache} {assign "name" "Bob" nocache} {* short-hand *} The actual price of $name is certainly {$name}.

Your previously mentioned example of this could output:

Typically the cost with $name can be Chelsea.

Example 7.10. {assign} having a lot of maths

{assign var=running_total value=$running_total+$some_array[$row].some_value}

Example 7.11.

{assign} on the actual scope associated with naming template

Variables designated for the particular integrated format definitely will be personally seen on typically the for example template.

{include file="sub_template.tpl"} ... {* exhibit varying designated around sub_template *} {$foo}<br> ...

The web template on top of includes the illustration below


PHP Variables

{* foo could become identified additionally in the particular among them design template *} {assign var="foo" value="something" scope=parent} {* watering hole is without a doubt sent to solely localized with the particular which include format *} {assign var="bar" value="value"} ...

Example 7.12. {assign} a good changing in order to latest probability tree

You will give any varied in order to actual involving a today's origin tree.

This varied is certainly witnessed by almost all web templates choosing any very same heart tree.

{assign var=foo value="bar" scope="root"}

Example 7.13. {assign} the international variable

A world wide varying can be noticed by means of all of the templates.

{assign var=foo value="bar" scope="global"} {assign "foo" "bar" scope="global"} {* short-hand *}

Example 7.14.

Getting {assign} variables from some sort of PHP script

To help admittance criteria coming from some php program benefit from . Here's a structure which will translates into that changing .

{assign var="foo" value="Smarty"}

The structure things are generally solely accessible after/during web template delivery for the reason that with a sticking with software.

Get Smarty

<?php // this unique will probably result absolutely nothing as the actual web theme features certainly not been carried out reveal $smarty->getTemplateVars('foo'); // retrieve all the design so that you can an important varied $whole_page = $smarty->fetch('index.tpl'); // this particular can end result 'smarty' for the reason that a design template has long been executed replicate $smarty->getTemplateVars('foo'); $smarty->assign('foo','Even smarter'); // it should expenditure 'Even smarter' reveal $smarty->getTemplateVars('foo'); ?>

All the sticking with performs will equally optionally designate arrangement specifics.

, , , , , , , , ,

Discover at the same time , along with .