Note: User-defined functions should be stored in the project application directory/common. php. Here is the key.
Template variable function call format: {$ varname | function1 | function2 = arg1, arg2 ,###}
Note:
{There must be no space between the symbol and the $ symbol, so there is no problem with the space of the following parameter;
### Parameter location of the template variable itself;
Multiple functions are supported, and spaces are supported between functions;
Function shielding is supported. In the configuration file, you can configure a list of Disabled functions;
Variable caching is supported. Repeated variable strings are parsed several times.
Example:
{$ WebTitle | md5 | strtoupper | substr = 0, 3}
{$ Number | number_format = 2}
{$ Varname | function1 | function2 = arg1, arg2 ,###}
Instance:
Copy codeThe Code is as follows:
Function Cate ($ cid ){
$ Cate = D ('cate ');
$ Cate = $ Cate-> where ('Id = '. $ cid)-> find ();
Return $ Cate ['title'];
}
I want to call this function in the template, so you can write it like this in the template.
{$ Vo. cid | cate ###}