Table of Contents
smarty学习笔记之常见代码段用法总结,smarty学习笔记
您可能感兴趣的文章:
Home php教程 php手册 smarty学习笔记之常见代码段用法总结,smarty学习笔记

smarty学习笔记之常见代码段用法总结,smarty学习笔记

Jun 13, 2016 am 08:43 AM
html code smarty

smarty学习笔记之常见代码段用法总结,smarty学习笔记

本文实例讲述了smarty常见代码段。分享给大家供大家参考,具体如下:

1、

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

Copy after login

说明:生成下拉菜单。values=一个数组,数组元素为列表值 selected=一个值,这个是默认的列

表值 output=一个数组,数组元素为显示的列表值

{html_checkboxes values=$cust_ids checked=$customer_id 
output=$cust_names separator="<br/>"}

Copy after login

说明:复选框。同上;separator="
"指以
分隔每个复选按钮的字符串

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

Copy after login

说明:单选按钮

2、

{counter start=0 skip=2 print=ture}

Copy after login

说明:计数器,其后使用时,以0 开始,每次增加 2 。

3、

{section loop=$data}
  <tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}">
  <td>{$data[rows]}</td>
  </tr>
{/section}

Copy after login

说明:轮回返回数组元素(或一个数列)值

4、

{assign var="name" value="Bob"}
The value of $name is {$name}.//The value of $name is Bob。

Copy after login

说明:赋值

5、

{fetch file="http://www.myweather.com/68502/" assign="weather"}

Copy after login

说明:fetch 用于从本地文件系统、HTTP或FTP上取得文件并显示文件的内容. 如果文件名称

以"http://"开头,将取得该网站页面并显示. 如果文件名称以"ftp://"开头,将从ftp服务器取得

该文件并显示.

6、

{html_image file="../path/relative/to/currdir/pumpkin.jpg"
border="1" height="100" width="100" alt="图片" href="1.html"}

Copy after login

说明:图片

7、

{html_select_date}

Copy after login

说明:创建日期下拉菜单. 它可以显示任意年月日

{html_select_time}

Copy after login

说明:用于创建时间下拉菜单. 它可以显示任意时分秒

8、

{html_table loop=$data cols=4 table_attr='border="0"'
tr_attr=$tr td_attr=$td}

Copy after login

说明:以$data数组元素形成一个4列的表。table_attl为表格属性,tr_attr为行属性,td_attr

为列属性

9、

{math equation="x + y" x=$height y=$width}

Copy after login

说明:数学运算函数

10、

{mailto address="me@domain.com" text="send me some mail"}

Copy after login

说明:生成电子邮件链接

11、

{popup}

Copy after login

说明:创建javascript弹出窗口,使用前必须先调用 popup_init 函数

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

您可能感兴趣的文章:

  • Ajax+smarty技术实现无刷新分页
  • Zend Framework实现Zend_View集成Smarty模板系统的方法
  • Codeigniter中集成smarty和adodb的方法
  • PHP文件缓存smarty模板应用实例分析
  • yii,CI,yaf框架+smarty模板使用方法
  • smarty高级特性之对象的使用方法
  • smarty高级特性之过滤器的使用方法
  • php实现smarty模板无限极分类的方法
  • smarty简单应用实例
  • Smarty使用自定义资源的方法
  • smarty中常用方法实例总结
  • Smarty最简单实现列表奇偶变色的方法
  • Smarty foreach控制循环次数的一些方法
  • CodeIgniter中使用Smarty3基本配置
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to write HTML scroll bar text box code How to write HTML scroll bar text box code Feb 19, 2024 pm 07:38 PM

Title: How to write HTML text box code with scroll bar The text box in HTML is one of the commonly used user input controls. In some cases, when the text content is too long, the text box will be displayed incompletely. At this time, we can add a scroll bar to the text box to support scrolling. This article will introduce in detail how to write HTML text box code with scroll bar effect, and give specific code examples. 1. Use the textarea element to create a text box. In HTML, we use the textarea element to create a text box.

How to use PHP and Smarty to achieve front-end and back-end separation development How to use PHP and Smarty to achieve front-end and back-end separation development Jun 25, 2023 pm 01:46 PM

In modern web development, the separation of front-end and back-end has become a very popular trend, which allows developers to better organize projects and improve the efficiency of project development. PHP and Smarty are two very commonly used technologies, which can be used to achieve front-end and back-end separation development. This article will introduce how to use PHP and Smarty to achieve front-end and back-end separation development. What is front-end and back-end separation development? In traditional web development, the front-end is mainly responsible for the presentation of the page and the logic of interaction with the back-end. The backend is mainly responsible for the business

A preliminary study on the template engine Smarty in PHP A preliminary study on the template engine Smarty in PHP May 11, 2023 pm 05:15 PM

Nowadays, website development is inseparable from an important component-template engine. A template engine refers to a tool that combines page templates and data to generate HTML code with a specific format. In various website development frameworks, the template engine is an essential component, because the template engine can greatly reduce the duplication of code and improve the dynamics of the page. One of the most common and popular template engines is Smarty. Smarty is a DSL (DomainSpecif

How to use Smarty template engine in PHP development How to use Smarty template engine in PHP development Jun 27, 2023 pm 01:28 PM

As a PHP developer, using a template engine is a natural choice. Smarty is a popular template engine that provides a way to separate HTML/CSS/JavaScript from PHP code, allowing developers to better organize and manage projects. In this article, we will learn how to use Smarty template engine during PHP development. 1. Install Smarty Before, we must install Smarty. In this article we will use Composer to install

How to use PHP and the Smarty template engine How to use PHP and the Smarty template engine May 11, 2023 pm 03:33 PM

PHP is a powerful server-side scripting language that can be used to develop web applications. In the early days of web development, programmers used a lot of HTML and JavaScript code to develop web applications. However, this approach is difficult to maintain and manage because the HTML and JavaScript code can become very complex. To solve this problem, the Smarty template engine was created. Smarty is a template engine developed based on PHP for managing and generating W

How to use Smarty with CakePHP? How to use Smarty with CakePHP? Jun 03, 2023 pm 03:10 PM

CakePHP is an open source PHP framework that provides rich features and tools to accelerate web application development. One of the powerful features is the template engine. By default, CakePHP uses PHP's native syntax for view rendering. However, sometimes we may want to use another template engine, such as Smarty. This article will introduce how to use Smarty in CakePHP. 1. What is Smarty? Smarty is a template-based PHP framework that

How to eliminate html code How to eliminate html code Nov 07, 2023 am 10:52 AM

Elimination methods: 1. Use a text editor; 2. Delete HTML tags; 3. Delete special characters; 4. Delete inline styles; 5. Delete script and style tags; 6. Use online tools.

what are thinkphp and smarty what are thinkphp and smarty Jun 14, 2022 pm 05:56 PM

thinkphp is an open source lightweight PHP framework that is used to simplify enterprise application development and agile WEB application development; using ThinkPHP, developers can develop and deploy applications more conveniently and quickly. Smarty is a PHP template engine that can better help developers separate program logic and page display (separation of business logic and display logic), so that programmers can change the logic content of the program without affecting the page design of the front-end staff, and the front-end staff can re- Modifying the page will not affect the program logic of the program.

See all articles