Note: Custom functions must be placed in the project application directory/common/common.php. Here's the key.
Function calling format of template variables: {$varname|function1|function2=arg1, arg2, ### }
Note: There can be no spaces between
{ and the $ symbol, and there will be no problem with spaces in the following parameters;
### represents the parameter position of the template variable itself;
Supports multiple functions, and spaces are supported between functions;
Supports function shielding function, and a list of prohibited functions can be configured in the configuration file;
Supports variable caching function , repeated variable strings are not parsed multiple times.
Usage example:
{$webTitle|md5|strtoupper|substr=0, 3}
{$number|number_format=2}
{$varname|function1|function2=arg1, arg2, ### }
Example:
Copy code The code is as follows:
function Cate($cid){
$Cate=D('Cate');
$Cate=$Cate->where('id='.$cid)-> find();
return $Cate['title'];
}
If I want to call this function in the template, I can write it like this in the template
{$vo.cid|cate=###}