This time to bring you thinkphp in the Volist label use case, thinkphp in Volist label use of what, the following is the actual case, together to see.
Property:
Name (required): The data template variable to output
ID (required): Loop variable
Offset (optional): Offset to output data
Length (optional): The lengths of the output data
Key (optional): The key variable of the loop, the default value is I
MoD (optional): Modulo the key value, default to 2
Empty (optional): If the data is displayed as a blank string
The result of the typical model's Select method is a two-dimensional array that can be output directly using the volist tag.
$User = M (' User '); $list = $User->select (); $this->assign (' list ', $list); <volist name= "list" id= "Vo" >{$ vo.id}{$vo .name}</volist>
Output even record
<volist name= "list" id= "Vo" mod= "2" ><eq name= "mod" value= "1" >{$vo .name}</eq></volist>
MoD starts counting from 0, here MoD cycle count is 0,1
MoD properties are also used to control the line breaks for a certain record, for example:
<volist name= "list" id= "Vo" mod= "5" >{$vo. Name}<eq name= "mod" value= "4" ><br/></eq></ Volist>
MoD loop count, 0,1,2,3,4 when the value is 4. That is, 5 lines of data in another line.
Output loop variable
<volist name= "list" id= "Vo" key= "K" >{$k}. {$vo .name}</volist>
Loop variable starting from 1 1, 2, 3, 4
If the key attribute is not specified, the loop variable i is used by default, for example:
<volist name= "list" id= "Vo" >{$i}. {$vo .name}</volist>
Comprehensive case:
<volist name= "Agentdata" id= "Vo" mod= "3" key= "K" empty= "temporarily no data" ><p style= "display:inline-block;width:280px; margin:3px; " ><input type= "Radio" class= "Regular-radio" value= "{sh: $vo. agent_id}" name= "agent_id" id= "Agent_{sh: $k}" <eq Name= "K" value= "1" >checked= "checked" </eq>><label for= "Agent_{sh: $k}" ></label><span style= "display:inline-block;padding:0px 0px 5px 5px;" >{sh: $vo. Name} phone ({sh: $vo. Tel}) </span></p>{sh: $mod}<eq name= "mod" value= "2" ><br/></ Eq></volist>
Effect
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP using the z-glyph sequence to print the binary tree steps
PHP gets a list of links from the back-to-front number of nodes steps