Detailed volist label in thinkphp

Through case examples to introduce the label volist thinkphp in this article to tell you in great detail, with reference to reference value, a friend in need reference under the bar, hoping to help you.

Yaezakura: how to become a must-see architect's knowledge from one yard Agriculture: directory Daquan (regularly updated)

Attributes:

Template variable data to be output: name (required)

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 cycle, the default value i

mod (Optional): modulo key value, the default is 2

empty (optional): If the data string is an empty display

Model results are usually select method returns a two-dimensional array, tags may be used directly volist output.

 

$User = M('User');

$list = $User->select();

$this->assign('list',$list);

<volist name="list" id="vo">

{$vo.id}

{$vo.name}

</volist>

The even record

 

<volist name="list" id="vo" mod="2" >

<eq name="mod" value="1">{$vo.name}</eq>

</volist>

mod counted from 0, where the loop count is 0 mod

Mod property and for controlling the recording of a certain wrap, for example:

<volist name="list" id="vo" mod="5" >

{$vo.name}

<eq name="mod" value="4"><br/></eq>

</volist>

mod cycle count, a value of 4 when 0,1,2,3,4 wrap. That is, five data exchange line.

Output loop variable

<volist name="list" id="vo" key="k" >

{$k}.{$vo.name}

</volist>

Loop variable starting at 1, 3, 4

If no key attributes, default loop variable i, for example:

<volist name="list" id="vo" >

{$i}.{$vo.name}

</volist>

Integrated Case:

<volist name="agentData" id="vo" mod="3" key="k" empty="暂时没有数据">

<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} 电话({sh:$vo.tel})</span>

</p>

{sh:$mod}

<eq name="mod" value="2"><br/></eq>

</volist>

Above hope to help everyone, many PHPer always encounter some problems and bottlenecks in the advanced time, write more business code no sense of direction, I do not know from where to start to ascend, which I compiled some information, including but not limited to: a distributed architecture, highly scalable, high-performance, high-concurrency, server performance tuning, TP6, laravel, YII2, Redis , Swoole, Swoft, Kafka, Mysql optimization, shell scripts, Docker, micro-services, Nginx, etc. more advanced knowledge required for advanced dry goods can be free for everyone to share , need to be added to my official group here .

Yaezakura: how to become a must-see architect's knowledge from one yard Agriculture: directory Daquan (regularly updated)

He published 189 original articles · won praise 12 · views 3626

Guess you like

Origin blog.csdn.net/weixin_43814458/article/details/103964967