Nov
24

ecshop中调用smarty的foreach-iteration函数     2009

 11:40    185    0   noel Ecshop/Ecmall/Smarty 不指定 | |
ecshop中调用smarty的foreach-iteration函数
  ecshop中的模板技术确实不错,ecshop的smarty也写的很好,foreach标签是ecshop中smarty用的最多的一个标签了。而foreach中的iteration非常有用。

    iteration其实是foreach循环中的下标,而且从1开始.直接循环。所以在ecshop销售排行中,很多人用这个来区分销售的图标.他是foreach下name的键值.{foreach name=top_goods from=$top_goods item=goods}


   <meta http-equiv="Content-Type" content="text/html; charset=gbk">
<div class="mod2">
<h1><span class="left"></span><span class="right"></span>销售排行</h1>
<!-- {foreach name=top_goods from=$top_goods item=goods}-->
  <ul class="top10 clearfix">
<li><img src="../images/top_{$smarty.foreach.top_goods.iteration}.gif" class="iteration" />
<!-- {if $smarty.foreach.top_goods.iteration<2}-->

    <table width="185" border="0">
  <tr>
    <td><a href="{$goods.url}" target="_blank"><img src="{$goods.thumb}" alt="{$goods.name&#124;escape:html}" class="topimg" height="80px" width="80px" /></a></td>
    <td>售价:<font class="f1">{$goods.price}</font></td>
  </tr>
</table>



<!-- {/if} -->
       <{if $smarty.foreach.top_goods.iteration<4}class="iteration1"{/if}>
      <a href="{$goods.url}" title="{$goods.name&#124;escape:html}" target="_blank">{$goods.short_name}</a><br />

      </li>
   <div style="clear:both;"></div>
    </ul>
  <!-- {/foreach} -->
</div>
    这个是ecshop销售排行的模板,他通过巧妙使用foreach来实现了图标的对应
.><img src="../images/top_{$smarty.foreach.top_goods.iteration}.gif" class="iteration" />

作者:noel@SEO
地址:http://www.laohucheng.com/post/416/
版权所有©转载时必须以链接形式注明作者和原始出处及本声明!

引用(0)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我