Home>Article>Backend Development> Usage of volist tag in thinkPHP
This article mainly introduces the usage of the volist tag in thinkPHP, and analyzes the functions, attributes and related usage skills of the volist tag in thinkPHP in the form of examples. Friends who need it can refer to it
The examples in this article describe thinkPHP Usage of volist tag. Share it with everyone for your reference, the details are as follows:
Attributes:
name (required) | Data template variable to be output |
id (required) | Loop variable |
offset (optional) | The data to be output offset |
length (optional) | The length of the output data |
key (optional) | The key variable of the loop, the default value is i |
mod (optional) | Take the modulo of the key value, the default is 2 |
empty (optional) | The string displayed if the data is empty |
Usually the result returned by the select method of the model is a two-dimensional Arrays can be output directly using the volist tag.
$User = M('User'); $list = $User->select(); $this->assign('list',$list);
{$vo.id} {$vo.name}
Output even records
{$vo.name}
mod starts counting from 0, here the mod loop count is 0,1
The Mod attribute is also used to control the line wrapping of certain records, for example:
{$vo.name}
mod loop count, 0,1,2,3,4 wrap when the value is 4. That is, 5 pieces of data are changed to one row.
Output loop variable
{$k}.{$vo.name}
The loop variable starts from 1 1, 2, 3, 4
If the key attribute is not specified, the loop variable i is used by default, for example:
{$i}.{$vo.name}
Comprehensive case:
checked="checked">{sh:$vo.name} 电话({sh:$vo.tel})
{sh:$mod}
Effect
##Related recommendations:Thinkphp’s volist tag nesting recycle
The above is the detailed content of Usage of volist tag in thinkPHP. For more information, please follow other related articles on the PHP Chinese website!