Variable adjuster: File naming format (modifier. php) Front-end invocation mode <{variable | Name: Parameter: Parameter ...} > can be used together, separated by |
<? PHP /* named format Smarty_modifier_ name (one must parameter $str, multiple optional parameters) $str Get the variable content that needs to be displayed */ function smarty_modifier_color ($str,$a,$b) {
//processing content $str= "<span style= ' color:$a; Font-size:$b; ' >$str</span> ";
return $STR;}
method: file naming format (function. Name. php) Front-end invocation method <{name key= variable key1= parameter key2= parameter ...}
<? PHP /* naming format Smarty_function_ name (requires a parameter) $ Args deposits all parameters defined by the front end into the array */ function Smarty_function_color ( $args ) { // get parameters $a = $args [' Key1 ' $b = $args [' Key2 ' return ... ;
Block function: File naming format (block. Name. php) Front-end invocation method <{name key1= parameter key2= parameter ...} > <{/name}>
<?PHP/*function naming format Smarty_block_ name (requires four parameters) $args Save all user-defined parameters to the array $content get all the contents of the block tag
$smarty template comes with tags and is generally useless $a judge whether the block label starts or ends, returns 1, ends with an empty*/functionSmarty_block_fontstyle ($args,$content,$smarty,$a){ //Ignore start tag to prevent two calls if executed when closing tag if(!$a) { //get user-defined parameters $color=$args[' Key1 '];
$fontsize = $args [' Key2 ']; //return to processed content return"<span style= ' color:$color; font-size: $fontsize' >$content</span> "; }}
Configuration file: File naming Format (name. conf)
Front-end invocation mode
<!-- --> {config_load file = ' name. conf ' section = ' block '} > <!-- --> < div style ></ div >
How to Write
[Block one]
property = value
property = value
......
[Block II]
Size=20
Color=red
......
88th Day leave PHP amarty template variable adjuster, method and block function basic writing format