函数
每个 Smarty 标签要么打印一个变量,要么调用某种函数。通过将函数及其属性包含在定界符中,可以进行处理和显示,例如:{funcname attr1="val1" attr2="val2"}。
示例
{config_load file="colors.conf"}
{include file="header.tpl"}
{insert file="banner_ads.tpl" title="My Site"}
{if $logged_in}
欢迎,<span style="color:{#fontColor#}">{$name}!</span>
{else}
你好,{$name}
{/if}
{include file="footer.tpl"}
-
自定义函数是通过插件实现的附加函数。你可以根据自己的喜好修改它们,或者创建新的函数。
{html_options}就是一个自定义函数的例子。
另请参见registerPlugin()