Table of Contents
Analysis of the usage of html:list tag in ThinkPHP, thinkphplist
Articles you may be interested in:
Home Backend Development PHP Tutorial Analysis on the usage of html:list tag in ThinkPHP, thinkphplist_PHP tutorial

Analysis on the usage of html:list tag in ThinkPHP, thinkphplist_PHP tutorial

Jul 12, 2016 am 09:01 AM
thinkphp Label

Analysis of the usage of html:list tag in ThinkPHP, thinkphplist

This article analyzes the usage of html:list tag in ThinkPHP with examples. Share it with everyone for your reference, the details are as follows:

Copy code The code is as follows:

The list tag in ThinkPHP's html tag library is powerful, but there is no documentation. I have to look at the source code. After a casual look, it is roughly as follows:

Datasource and show are required. Datasource is the name of the data source, which is the variable pointed to by assign. Show is the most complicated one. , we will talk about it later

pk is the primary key name, the default is id; style is the class of CSS style , because the entire list tag will be compiled into a table, for example, here is mylist, then the table.mylist style in the style sheet is Will be used here; whether checkbox displays the check box; whether action displays the action column

show part: Separate different fields with commas, such as:

id:number|8%,account:username|90px:edit:account,phone:address,remark:note,status|getStatus:status

Each field can be divided into several parts with colon as the separator, and each part can be separated by |,

The first part: id, represented as the id field in the result set, status|getStatus, represents the status field, but it needs to be processed by the getStatus function. The function here can be PHP's own function, or it can be thinkphp's common/functions. Functions in php can also be custom functions in the project directory conf/common.php
Part 2: Number | 8% means that the display field in the title row is the title, the width is 8%, user name | 90px in 90px is also the width
The third part: such as edit, represents the edit function of javascript. Its parameter is the primary key value. For example, for a user with id 1, the displayed value at the username (account) is a link. After clicking, javascript:edit(1) will be executed. ;
Part 4: This part generally does not need to be set. For example, the account number means that when the "user name" in the title line of the account (user name) is moved with the mouse, "Sort by Account" will be displayed. If not set, it will be "Sort by User". "Sort by name", that is to say, if it is not set, the words between "by" and "sort" will display the same as the title.

As for actionlist, if action="true" is set, but actionlist is not set, the default "edit" and "delete" operations will be displayed, and the parameters are all the values ​​of the primary key. In terms of our self-set function , for example, set to changePassword: change password, it will become something like Copy code The code is as follows:disable, otherwise In general, the html:list function is very good, especially the ability to customize the width of each column. However, there are still some shortcomings or some areas that developers need to pay attention to :

1. If there is | in the actionlist, it will be linked to the status field in the datasource. This is very unpleasant. Because there may be more than two statuses, and secondly, other fields may also need to display different text and perform different executions according to the situation. Operation.
2. The link is expressed in javascript, which is okay sometimes, but sometimes I prefer to express it directly in url, such as
edit
3. The javascript function naming in the link and the naming of some html elements are very simple, and may conflict with the naming of some js scripts or html elements. Function names such as del, change, edit, over, out, etc., html elements such as checkbox The id is check
4. The function of sorting the title by XX cannot be disabled. There are many times when this function is not needed, especially when every row is not required to have this function. Of course, it can be modified in the js function.
5. The above js functions are not defined in tags, but only called. The functions are defined in their own js scripts. I directly used the RABC example of thinkphp, so I did not study the specific js files, and I don’t want to study them for the time being. . But if you add custom operations, you have to write your own js function

TP’s tag library is a good thing.

For example, a label list containing checkboxes could be written like this:
Copy code The code is as follows:

Not much to say about id and name
datasource is the content information passed by the PHP code
show:""Inside is the column information of the table
id: ID represents the information in the datasource with the field name id, which is displayed under the column named ID
.

If yes
articleTitle: Article title: function

means that the content under the field articleTitle is displayed under the "article title" column. At the same time, a javascript:function ("primary key") link is added to each "article title" for other operations.

checkbox="true" means displaying the checkbox
style="list" represents the style using list.
action="true" means displaying the action column
actionlist="edit: edit, delarticle: delete, sh: review" represents the content of the action column

Format:

Execute function: display name.

I hope this article will be helpful to everyone’s PHP programming based on the thinkPHP framework.

Articles you may be interested in:

  • The html:list tag in thinkphp passes multiple parameter instances
  • How to use thinkPHP’s Html template tags
  • ThinkPHP Using to implement a three-level loop code example
  • Thinkphp's volist tag nested loop usage tutorial
  • Verification method to determine the last record of the volist loop in the ThinkPHP template
  • Introduction to the usage of volist tags in Thinkphp
  • Overview of the usage of thinkphp special tags
  • Custom tag library examples under ThinkPHP group
  • ThinkPHP tag production tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1089932.htmlTechArticleAnalysis of the usage of html:list tag in ThinkPHP, thinkphplist This article analyzes the usage of html:list tag in ThinkPHP. Share it with everyone for your reference, the details are as follows: Copy the code The code is as follows...
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 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
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 run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

How to search for text across all tabs in Chrome and Edge How to search for text across all tabs in Chrome and Edge Feb 19, 2024 am 11:30 AM

This tutorial shows you how to find specific text or phrases on all open tabs in Chrome or Edge on Windows. Is there a way to do a text search on all open tabs in Chrome? Yes, you can use a free external web extension in Chrome to perform text searches on all open tabs without having to switch tabs manually. Some extensions like TabSearch and Ctrl-FPlus can help you achieve this easily. How to search text across all tabs in Google Chrome? Ctrl-FPlus is a free extension that makes it easy for users to search for a specific word, phrase or text across all tabs of their browser window. This expansion

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Nov 22, 2023 pm 12:01 PM

"Development Suggestions: How to Use the ThinkPHP Framework to Implement Asynchronous Tasks" With the rapid development of Internet technology, Web applications have increasingly higher requirements for handling a large number of concurrent requests and complex business logic. In order to improve system performance and user experience, developers often consider using asynchronous tasks to perform some time-consuming operations, such as sending emails, processing file uploads, generating reports, etc. In the field of PHP, the ThinkPHP framework, as a popular development framework, provides some convenient ways to implement asynchronous tasks.

How is the performance of thinkphp? How is the performance of thinkphp? Apr 09, 2024 pm 05:24 PM

ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

See all articles