Variables
Template variables start with the $dollar sign. They can contain numbers,
letters and underscores, much like a
PHP variable.
You can reference arrays
by index numerically or non-numerically. Also reference
object properties and methods.
Config file variables
are an exception to the $dollar syntax
and are instead referenced with surrounding #hashmarks#, or
via the
$smarty.config variable.
Variables
bar} <-- display the object property "bar"
{$foo->bar()} <-- display the return value of object method "bar"
{#foo#} <-- display the config file variable "foo"
{$smarty.config.foo} <-- synonym for {#foo#}
{$foo[bar]} <-- syntax only valid in a section loop, see {section}
{assign var=foo value='baa'}{$foo} <-- displays "baa", see {assign}
Many other combinations are allowed
{$foo.bar.baz}
{$foo.$bar.$baz}
{$foo[4].baz}
{$foo[4].$baz}
{$foo.bar.baz[4]}
{$foo->bar($baz,2,$bar)} <-- passing parameters
{"foo"} <-- static values are allowed
{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}
]]>
Request variables such as $_GET, $_SESSION etc are available via the
$smarty reserved variable.
See also $smarty reserved variables,
Config Variables
{assign}
and
assign().