ecshop模板取模运算,取余运算符

来源:互联网 发布:cfve软件下载 编辑:程序博客网 时间:2024/05/12 15:41

比如模板中.文章列表中需要调用20个文章,要求每4个商品后面就增加一个换行符.可以这样写

{foreach from=get_advlist_by_id(6) item=ad name=index_image}<div class="xb2 xl3"><img width="90%" src="{$ad.image}" /></div>  {if $smarty.foreach.index_image.iteration mod 4 eq 0}  <br/>{/if}{/foreach}

取模运算,就是取余数.比如8会被4整除,所 以余数为0,所以.第8个文章后面,就要增加 一个换行符.

其中,eq表示等于,mod表示模运算.

 

扩展知识.

eq :相等equal
neq not equal:不等于
gt greater than:大于
lt less than:小于
lte less than or equal:小于等于
gte great than or equal:大于等于
is even:是偶数
is odd:是奇数
is not even:不是偶数
is not odd不是奇数
not:非
mod:取余

0 0