Home > Backend Development > PHP Tutorial > The html:list tag in thinkphp passes multiple parameter examples, thinkphplist_PHP tutorial

The html:list tag in thinkphp passes multiple parameter examples, thinkphplist_PHP tutorial

WBOY
Release: 2016-07-13 10:15:35
Original
1031 people have browsed it

The html:list tag in thinkphp passes multiple parameter instances, thinkphplist

The example in this article describes the solution to the problem of passing multiple parameters in the html:list tag in thinkphp, and shares it with everyone for your reference. The specific analysis is as follows:

This change is valid for thinkphp 2.0 version, thinkphp 3.0 version has not been tested.
Mainly modify the _list method of this file /Thinkphp/Lib/Think/Template/Taglib/TabLibHtml.class.php

The code parts with new content commented out are newly added
Mainly through -- splitting multiple parameters (will be automatically replaced with,)

Copy code The code is as follows:
public function _list($attr)
{
$tag = $this->parseXmlAttr($attr,'list');
$ ID = $ tag ['ID']; // Table ID
          $datasource = $tag['datasource'];                                                                                                                                                                               $ Pk = Empty ($ tag ['pk'])? 'ID': $ tag ['pk']; // The main key name, the default ID
         $style                                                                                                                                                                                        = $tag['style'] $name = !empty($tag['name'])?$tag['name']:'vo'; //Vo object name
           $action                                                                                                                                                                                                                                   $key                                                                                                                                                                                          $sort = $tag['sort']=='false'?false:true;
$checkbox = $tag['checkbox']; // Whether to display Checkbox
If(isset($tag['actionlist'])) {
              $actionlist = explode(',',trim($tag['actionlist'])); //Specify function list
}
If(substr($tag['show'],0,1)=='$') {
$show = $this->tpl->get(substr($tag['show'],1));
         }else {
$show = $tag['show'];
}
$ Show = Explode (',', $ show); // List display field list
//Calculate the number of columns in the table
$colNum = count($show);
If(!empty($checkbox)) $colNum++;
If(!empty($action)) $colNum++;
If(!empty($key)) $colNum++;
//Display starts
$parseStr = "n";
           $parseStr .= '';
$parseStr .= '';
$parseStr .= '';
//Fields that need to be displayed in the list
         $fields = array();
foreach($show as $val) {
           $fields[] = explode(':',$val);
}
If(!empty($checkbox) && 'true'==strtolower($checkbox)) {//If specified, the checkbox column needs to be displayed
$parseStr .=' ';
}
If(!empty($key)) {
            $parseStr .= '';
        }
        foreach($fields as $field) {//显示指定的字段
            $property = explode('|',$field[0]);
            $showname = explode('|',$field[1]);
            if(isset($showname[1])) {
                $parseStr .= '';
            }else{
                $parseStr .= $showname[0].'';
            }
        }
        if(!empty($action)) {//如果指定显示操作功能列
            $parseStr .= '';
        }
        $parseStr .= '';
        $parseStr .= '         if(!empty($checkbox)) {
            $parseStr .= 'onmouseover="over(event)" onmouseout="out(event)" onclick="change(event)" ';
        }
        $parseStr .= '>';
        if(!empty($checkbox)) {//如果需要显示checkbox 则在每行开头显示checkbox
            $parseStr .= '';
        }
        if(!empty($key)) {
            $parseStr .= '';
        }
        foreach($fields as $field) {
            //显示定义的列表字段
            $parseStr   .=  '';
}
If(!empty($action)) {//Show function operation
If(!empty($actionlist[0])) {//Display the specified function item
                         $parseStr .= '';
                            //echo $parseStr;
                           //exit();
            }
}
$parseStr .= '< ;/tr>
No';
            }else {
                $parseStr .= '
';
            }
            $showname[2] = isset($showname[2])?$showname[2]:$showname[0];
            if($sort) {
                $parseStr .= ''.$showname[0].'
操作
{$i}';
            if(!empty($field[2])) {
                // 支持列表字段链接功能 具体方法由JS函数实现
                $href = explode('|',$field[2]);
                if(count($href)>1) {
                    //指定链接传的字段值
                    // 支持多个字段传递
                    $array = explode('^',$href[1]);
If(count($array)>1) {
foreach ($array as $a){
$temp[] = ''{$'.$name.'.'.$a.'|addslashes}'';
                                                                                                                                                      $parseStr .= '';
                       }else{
$parseStr .= '
';
                 }
                      }else {
                                                                                                                                                                                                                                                                          to $parseStr .= '
';
                }
            }
If(strpos($field[0],'^')) {
                     $property = explode('^',$field[0]);
foreach ($property as $p){
                               $unit = explode('|',$p);
If(count($unit)>1) {
$parseStr .= '{$'.$name.'.'.$unit[0].'|'.$unit[1].'} ';
                           }else {
$parseStr .= '{$'.$name.'.'.$p.'} ';
                 }
                }
               }else{
                      $property = explode('|',$field[0]);
If(count($property)>1) {
//Conversion -- for , pass multiple parameters
                              $property[1] = str_replace('--',',',$property[1]);//New content here
$parseStr .= '{$'.$name.'.'.$property[0].'|'.$property[1].'}';
                      }else {
$parseStr .= '{$'.$name.'.'.$field[0].'}';
                }
            }
If(!empty($field[2])) {
$parseStr .= '
';
            }
$parseStr .= '
';
                    foreach($actionlist as $val) {
                                                   //Apply javascript
If(strpos($val,':')) {
        $a = explode(':',$val);
If(count($a)>2) {
$parseStr .= ''. $a[1].' ';
}else {
$parseStr .= ''.$a[ 1].' ';
}
}else{
//Apply php function
$array = explode('|',$val);
If(count($array)>2) {
$parseStr .= ' '. $array[2].' ';
}else{
//Conversion -- for , pass multiple parameters
                                                                                                                                                                                                                                                                                                    through $parseStr .= ' {$'.$name.'.'.$val.'} ';
}
}
                }
$parseStr .= '
';
             $parseStr .= "nn";
          return $parseStr;
}
Template calling demonstration:

Copy code The code is as follows:
The method getTaskCategory passes 3 parameters in order:

$user['task_category']
$user['exe_user']
$user['id']

The method printAccept passes 3 parameters in order:

$user['status']
$user['exe_user']
$user['id']

Among them:


Copy code The code is as follows:
task_category|getTaskCategory=$user['exe_user']--$user['id']:

with
Copy code The code is as follows:
status|printAccept=$user['exe_user']--$user['id'],task_track: tracking
Demo for passing multiple parameters

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

html:link passes multiple parameters

If the passed parameter does have a value, it should be afaa.jsp?z=3&y=2&x=1. In your case above, it may be because the value you passed is empty or "" and it is not after the equal sign. Displays the attribute's value. & is a symbol used to pass multiple parameters, which plays the role of an interval between attributes

How to pass parameters through the anchor tag () of a hyperlink in HTML?

Use question marks and ampersands to carry values, such as this example
anchor tag
? The following second_id= parameter can be used to receive the value passed by second_id on the next page, that is, 3002
asp reception is written like this
second_id=Request.QueryString("second_id")
response.write( second_id)
then the input will display 3002

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/903487.htmlTechArticleThe html:list tag in thinkphp passes multiple parameters examples, thinkphplist This article tells about the html:list tag in thinkphp The solution to the problem of passing multiple parameters is shared with everyone for your reference...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template