azett 52bf429a01 Replaced Smarty 2.6.31-dev with v 4.0.4, keeping the FP-specific Smarty plugins.
Updated calls to current Smarty API (register_function()/register_modifier()/register_block() -> registerPlugin(); assign_by_ref() -> assignByRef()).
Fixed file includes in templates with quotes.
Removed SmartyValidate.class.php includes.

Still work in progress as some errors still appear!
2022-01-23 15:02:33 +01:00

1.3 KiB

Functions

Every Smarty tag either prints a variable or invokes some sort of function. These are processed and displayed by enclosing the function and its attributes within delimiters like so: {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}
    Welcome, <span style="color:{#fontColor#}">{$name}!</span>
{else}
    hi, {$name}
{/if}

{include file="footer.tpl"}
  • Both built-in functions and custom functions have the same syntax within templates.

  • Built-in functions are the inner workings of Smarty, such as {if}, {section} and {strip}. There should be no need to change or modify them.

  • Custom functions are additional functions implemented via plugins. They can be modified to your liking, or you can create new ones. {html_options} is an example of a custom function.

See also registerPlugin()