Html:list tag usage analysis in thinkphp, thinkphplist_php tutorial

Source: Internet
Author: User

Html:list label usage analysis in thinkphp, thinkphplist


This paper analyzes the usage of html:list tags in thinkphp. Share to everyone for your reference, as follows:

Copy the Code code as follows:

The list tag in the thinkphp's HTML tag library is powerful, but has no documentation. Had to look at the source. So-so looked down, probably as follows:

DataSource and Show must be, DataSource is the data source name, which is the variable that assign points to, show is the most complex , and so on.

PK is the primary key name, the default is Id;style is the CSS style class, because the entire list tag will be compiled into a table, such as here is mylist, then the style sheet table.mylist style will be used here; CheckBox Whether the check box is displayed or Action column is displayed

Show section: Separate the fields with commas, such as:

ID: Ref. |8%,account: User name |90px:edit: Account number, Phone: address, remark: remark, Status|getstatus: status

In each field, a colon is a delimiter that can be divided into parts, each of which can be separated by |

The first part: ID, expressed as the ID field in the result set, Status|getstatus, represents the Status field, but to be processed by the GetStatus function, the function here can be PHP own function, or it can be thinkphp common/ A function in functions.php, or a custom function in the project directory conf/common.php
The second part: The number |8% indicates that the header row displays the field as the title, the width is 8%, the user name |90px 90px is also the width
The third part: such as edit, the edit function of the JavaScript, its parameters as the primary key value, such as the user ID 1, the user name (account) display value is a link, click Will execute Javascript:edit (1);
Part IV: This section generally does not need to set up, such as account number, indicating that the "user name" in the header row of accounts (username) mouse over the above will show "by Account Sort", and if not set, is "Sort by user name", that is not set the words "press" and "sort" A few words in the middle are the same as the title display.

Again actionlist, if action= "true" is set, but ActionList is not set, the default edit and delete actions are displayed, and the parameters are the values of the primary key. In terms of our own functions, for example, set to ChangePassword: Change the password, here it will become similar to the copy code code is as follows: Change password

If there is |, there is a special, the current HTML tag Library force to interpret this situation as the action of the status, that is, the DataSource must have a Status field, this field flase, then show | The previous part, otherwise, the latter part, specifically said: Forbid|resume: Disable | Restore, disable if status is 0, otherwise restore

Overall, html:list function is very good, especially in which you can customize the width of each column is very good. But there are some deficiencies or some developers need to be aware of :

1. If there is a | In ActionList, it is very uncomfortable to hook up with the Status field in DataSource. Because there may be more than two states, and the other fields may also need to display different text depending on the situation to perform different actions.
2. Links are expressed in JavaScript, sometimes in line, but sometimes prefer to be represented directly by URLs, such as editing
3. The JavaScript function name in the link and some HTML element naming is very simple, it may be with some JS script or HTML element naming conflict, function name such as Del,change,edit,over,out, etc. The ID of the HTML element, such as checkbox, is check
4. The title of the sort by XX function cannot be disabled. There are many times when this functionality is not required, especially if each line is not required. Of course, you can modify it in the JS function.
5. The above JS function is not defined in the label, but just called. function definition in their own JS script, I am directly using the thinkphp of the RABC example, so also did not study the specific JS file, for the time being do not want to study. But if you add a custom action, Then you have to write the JS function yourself.

The tag library of TP is a good thing.

For example, a list of labels that contain check boxes can be written like this:
Copy the Code code as follows:

ID and name don't say much.
DataSource is the content information that the PHP code passes over
Show: "" Inside is the column information of the table
Id:id represents the information in the DataSource field named ID, which is displayed under the column named ID .

If it is
ArticleTitle: article title: function

The representative means that the contents under ArticleTitle are displayed under the column titled "article title", and a link to javascript:function ("PRIMARY key") is added for each "article title" for other actions

Checkbox= "true" for display check box
Style= "List" represents the style of using list.
Action= "True" represents the Display Action column
actionlist= "EDIT: Editor, delarticle: Delete, SH: Audit" represents the contents of the Action column

Format:

Execute function: Display name.

It is hoped that this article is helpful to the PHP program design based on thinkphp framework.

Articles you may be interested in:

    • thinkphp the html:list label to pass multiple argument instances
    • thinkphp How to use HTML template tags
    • Thinkphp implementation of three-level loop code example
    • thinkphp the volist tag nesting loop usage Tutorial
    • Validation method for determining the last record of the Volist loop in a thinkphp template
    • Introduction to Volist label usage in thinkphp
    • thinkphp Special Label Usage overview
    • Custom Tag Library instance under thinkphp Group
    • thinkphp Label Making Tutorial

http://www.bkjia.com/PHPjc/1089932.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089932.html techarticle html:list Label usage analysis in thinkphp, thinkphplist this paper analyzes html:list label usage in thinkphp. Share to everyone for reference, as follows: Copy code code as follows ...

  • 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.