notation: <{Variable name | method name [: Parameter]}>
Principle: Executes the variable name as the first parameter of the method, the return value of the output function to this page
Folder: Plugins/modifier. Method name. php
Application Examples:
<!--system comes with -<Div><{$test|capitalize}></Div>//Capitalize first letter<Div><{$money|cat: "$"}></Div>//connection string output hello$<Div><{"$" |cat:$money}></Div>//Output $hello<Div><{$zifu|count_characters}></Div>//Character count, where the kanji is a character, a space is two characters, the decimal point is a character<Div><{$duanluo|count_paragraphs}></Div>//Paragraph Count<Div><{$yuju|count_sentences}></Div>//Statement Count<Div><{$danci|count_words}></Div>//Word Count<Div><{$riqi|date_format: "%d%T"}></Div>//Format Date Time<Div><{$riqi|date_format: "%y-%m-%d%h:%m:%s"}></Div>remark:%T-current time, same as%h:%m:%s%d-same as%m/%d/%y%y-decimal year without century (range from 00 to one)%y-decimal years including decimal year%h-24 Hour (range from 00 %i-12 hours Decimal hours (range from 00 to)%m-Decimal month (range from 01 to)%m-decimal minutes%s-Decimal seconds%j-day of the Year, decimal number (range 001 to 366)%d -Day of the Month, decimal number (range from 01 to +)<Div><{$moren|default: "Hello"}></Div>//The default worth variable is not set or is an empty string, the output is replaced by the given default value. <Div><{$suojin|indent:10}></Div>//character indent, displayed in source code<Div><{$zhengze|regex_replace: "/\d/": "QQ"}></Div>//Regular replacement<Div><{$zhengze|replace: "L": "8"}></Div>//Replace<Div><{$jiequ|truncate:8: "..."}></Div>//intercept, refers to eight characters including three points<!--Custom -style <div><{$ceshi |yangshi: "Blue":20}></div>
Method page: Modifier.yangshi. php<? PHP function Smarty_modifier_yangshi ($str,$color= "Red",$size= "+") { $str = "<span style= ' color:{$color}; font-size:{$size}px ' >{$str}</span> "; return $str ;}
Intercept <div><{$jiequ |substr:8: "* * *"}></div>
Method page: Modifier.substr. PHP
<? PHP function smarty_modifier_substr ($str,$num=10,$end= "...") { $strsubstr($str, 0,$num-3); $str $str. $end ; return $str ;}
Sex <div><{$sex |sexname}></div>
<? PHP function smarty_modifier_sexname ($sex) { /*if ($sex) { return "Male"; } else { return "female"; } */ return $sex? " Male ":" Female ";}
National <div><{$nation |nationname}></div>
Method page: Modifier.nationname.PHP
<?PHPfunctionSmarty_modifier_nationname ($nation){ $db=NewMysqli ("localhost", "root", "123", "MyDB"); $sql= "SELECT name from Nation where Code= ' {$nation}‘"; $result=$db->query ($sql); $attr=$result-Fetch_row (); return $attr[0];} The variable adjuster method cannot call class dbda.php, error
Smarty Variable Adjuster