Volist Basic Syntax
Volist label (circular output data) |
Closed |
Non-closed label |
Property |
Name (required): Data template variable to output ID (required): Loop variable Offset (optional): Offset to output data Length (optional): Lengths of output data Key (optional): The key variable of the loop, the default value is I MoD (optional): Modulo key value, defaults to 2 Empty (optional): If the data is displayed in an empty string |
Friends who have used smarty for PHP development should know that the Smarty template determines whether the Foreach loop is the last one to use $ Smarty.foreach.name.last to determine whether the cycle to the last record, in the thinkphp How to judge? The common loops in thinkphp templates are volist, and Volist's various attributes do not directly judge this. Here's how to judge the last record in thinkphp volist.
Example
The code is as follows |
|
<volist name= "list" id= "Vo" offset= "5" length= ' > User name: {$vo [' username ']}<br/> E-mail: {$vo [' email ']}<br/> Registration time: {$vo [' regdate ']|date= ' y-m-d h:i ', ###} </volist> |
This is not a judge is not the last function, Baidu has such an example
The code is as follows |
|
<volist name= "list" id= "Vo" > <volist name= "Slist" id= "S" > <if condition= "$s. SID eq $vo [' id '] ' >/or <if condition= $s [' Sid '] eq $vo [' id '] ' > Content..... </if> </volist> </volist>
|
This discovery is normal to use, said a bunch of crap, let's get to the point.
The code is as follows |
|
<volist name= ' lists ' id= ' list ' > <li <if condition= "$i eq count ($lists)" >class= "Last" </if>> <a href= "/tag/thinkphp" >thinkphp tutorials </a> </li> </volist> |
The $i in the above code snippet is a count variable in the Volist loop, and the default name is $i, so you can use it without declaring it directly