This article mainly introduces the usage of common code segments of smarty learning notes, and summarizes and analyzes the meanings and usage of common code segments of Smarty using examples, for more information, see the examples in this article. We will share this with you for your reference. The details are as follows:
1,
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
Description: generate a drop-down menu. Values = an array. the array element is the list value selected = a value. this is the default column.
Table value output = an array. the array element is the displayed list value.
{html_checkboxes values=$cust_ids checked=$customer_id output=$cust_names separator="
"}
Note: check box. Same as above; separator ="
"Refers
String that separates each check button
{html_radios values=$cust_ids checked=$customer_idoutput=$cust_names separator="
"}
Note: single-choice buttons
2,
{counter start=0 skip=2 print=ture}
Note: The Counter starts with 0 and increases by 2 at a time.
3,
{section loop=$data} {$data[rows]} {/section}
Returns the value of an array element (or a series ).
4,
{assign var="name" value="Bob"}The value of $name is {$name}.//The value of $name is Bob。
Description: value assignment
5,
{fetch file="http://www.myweather.com/68502/" assign="weather"}
Description: fetch is used to obtain a file from the local file system, HTTP or FTP and display the file content. if the file name
Starting with "http: //", the website page will be obtained and displayed. if the file name starts with "ftp: //", it will be obtained from the ftp server
This file is displayed.
6,
{Html_image file = ".. /path/relative/to/currdir/pumpkin.jpg "border =" 1 "height =" 100 "width =" 100 "alt =" image "href =" 1.html "}
Description: Images
7,
{html_select_date}
Description: create date drop-down menu. it can display any year, month, or day
{html_select_time}
Description: it is used to display any time, minute, and second in the creation time drop-down menu.
8,
{html_table loop=$data cols=4 table_attr='border="0"'tr_attr=$tr td_attr=$td}
Note: a 4-column table is formed with $ data array elements. Table_attl is a table attribute, tr_attr is a row attribute, and td_attr
Column attribute
9,
{math equation="x + y" x=$height y=$width}
Description: mathematical functions
10,
{mailto address="me@domain.com" text="send me some mail"}
Note: an email link is generated.
11,
{popup}
Note: to create a javascript pop-up window, you must call the popup_init function before use.
I hope this article will help you design PHP programs based on the smarty template.