88th Day leave PHP amarty template variable adjuster, method and block function basic writing format

Source: Internet
Author: User
Tags closing tag smarty template

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.