Usage of volist tag in thinkPHP

不言
Release: 2023-03-30 11:40:02
Original
1890 people have browsed it

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);
Copy after login

{$vo.id}
{$vo.name}
Copy after login

Output even records


{$vo.name}
Copy after login

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}

Copy after login

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}
Copy after login

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}
Copy after login

Comprehensive case:


checked="checked">{sh:$vo.name} 电话({sh:$vo.tel})

{sh:$mod}
Copy after login

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!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!