Smarty learning notes: common code snippet usage summary, smarty learning notes

Source: Internet
Author: User
Tags mathematical functions smarty template zend framework

Smarty learning notes: common code snippet usage summary, smarty learning notes

This example describes common code segments of smarty. We will share this with you for your reference. The details are as follows:

1,

<select >  {html_options values=$cust_ids selected=$customer_id output=$cust_names}</select>

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="<br/>"}

Note: check box. Same as above; separator = "<br/>" indicates a string that separates each check button with <br/>

{html_radios values=$cust_ids checked=$customer_idoutput=$cust_names separator="<br/>"}

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}  <tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}">  <td>{$data[rows]}</td>  </tr>{/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.

Articles you may be interested in:
  • Ajax + smarty Technology for refreshing pagination
  • Zend Framework Implementation Zend_View integration Smarty template System Method
  • How to integrate smarty and adodb in Codeigniter
  • PHP File Cache smarty template application instance analysis
  • Yii, CI, yaf framework + smarty template usage
  • Usage of objects with smarty advanced features
  • Usage of filters for smarty advanced features
  • Php implementation of the smarty template infinitus Classification Method
  • Smarty simple application instance
  • How Smarty uses custom Resources
  • Summary of examples of common methods in smarty
  • Smarty is the simplest way to achieve the parity color of the list.
  • Some methods for Smarty foreach to control the number of loops
  • Use the basic configuration of Smarty3 in CodeIgniter

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.