Php 如何使用模板lite计数
我有一个这样的脚本。下面的代码用每个foreach对象创建一个新的Php 如何使用模板lite计数,php,template-lite,Php,Template Lite,我有一个这样的脚本。下面的代码用每个foreach对象创建一个新的。 我想要的是在计数器为4时创建html标记。 {foreach from=$books value=book} <div id="box1" class="box"> <div id="box2" class="box"> <img src="{$imageUrl}/{$book.image}" width="145" height="205"></div&g
。
我想要的是在计数器为4时创建html标记。
{foreach from=$books value=book}
<div id="box1" class="box">
<div id="box2" class="box"> <img src="{$imageUrl}/{$book.image}" width="145" height="205"></div>
<div id="box3" class="box">
<div class="baslik_kitap">{$book.title}</div>
<div class="baslik_kitap2"></div>
<div class="baslik_kitap"></div>
<div class="baslik_kitap2">{$book.description|truncate:75:"..."}.</div>
<div class="baslik_kitap"><a href="http://cmkzl.nokta.com/kitaplar/{$book.title}"><img src="{$imageUrl}/detaylar_btn.png" width="143" height="51"></a></div>
</div>
</div>
{/foreach}
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
{foreach from=$books value=book}
{$book.title}
{$book.description | truncate:75:“…”}。
{/foreach}
下面的代码使用每个对象创建
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
为了在计数器为4时创建
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
这是我写的
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
{foreach from=$books value=book}
{计数器开始=0跳过=1打印=错误}
{$book.title}
{$book.description | truncate:75:“…”}。
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
{if counter eq 4}//此处计数器必须为0,然后foreach必须继续使用新计数器
{/foreach}
我该怎么做呢?嗯,从未使用过templatelite,但从文档中可以看出,您可以通过以下方式获得所需:
</div>
</div>
{if counter eq 4 } // here counter must be 0 and then foreach must continue with new counter
{/foreach}
{counter start=0 print=false assign=mycounter}
{if $mycounter is div by 4}
<li></li>
{/if}
{counter start=0 print=false assign=mycounter}
{如果$mycounter被4除掉}
{/if}