Smarty File References:
{include file= "HEAD.TPL"}
{include file= "HEAD.TPL" sitename= "blog Park"} Property sitename is passed to HEAD.TPL, you can call {$sitename} in the file
Use of functions in Smarty:
1. Use the PHP function directly:
Form: {variable | php built-in function: Parameter 2: Parameter 3}
Date ("y-m-d", $time)----> {"y-m-d" | Date: $time}
Str_replace (' d ', ' H ', $STR)---> {' d ' | str_replace: ' h ': $str}
2. Custom functions: Registering custom functions using the Registerplugin method
Form: {function name parameter 1 = parameter value parameter 2 = parameter value}
In the PHP file:
function test ($params) {
$p 1= $params [' P1 '];
$p 2= $params [' P2 '];
Return $p 1. $p 2;
}
$smarty->registerplugin (' function ', ' f_test ', ' test '}; Register the test function and use f_test in the template file
In the template file:
{f_test p1= ' abc ' p2= ' EDF '} This will pass an array of arrays to the function test (
[' p1 '] = ' abc ',
[' p2 '] = ' def '
)
Note
Smarty Basic syntax file references, and function usage