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 ml; 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|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|escape:html}” target=”_blank”>{$goods.short_name}</a><br />
< >
<div></div>
</ul>
<!– {/foreach} –>
</div>
这个是ecshop销售排行的模板,他通过巧妙使用foreach来实现了图标的对应.><img src=”../images/top_{$smarty.foreach.top_goods.iteration}.gif” class=”iteration” />
巧用ecshop smarty中iteration
Search
Latest Comments
Categories
Archives
- 2025 年 10 月 (248)
- 2025 年 9 月 (58)
- 2023 年 2 月 (1)
- 2022 年 3 月 (1)
- 2021 年 2 月 (1)
- 2020 年 7 月 (1)
- 2019 年 9 月 (2)
- 2018 年 9 月 (1)
- 2018 年 8 月 (2)
- 2018 年 6 月 (2)
- 2018 年 5 月 (3)
- 2018 年 2 月 (2)
- 2018 年 1 月 (1)
- 2017 年 12 月 (2)
- 2017 年 10 月 (1)
- 2017 年 7 月 (1)
- 2017 年 4 月 (1)
- 2017 年 2 月 (1)
- 2016 年 11 月 (1)
- 2016 年 10 月 (1)
- 2016 年 8 月 (2)
- 2016 年 7 月 (1)
- 2016 年 6 月 (3)
- 2016 年 4 月 (4)
- 2016 年 3 月 (5)
- 2016 年 2 月 (5)
- 2016 年 1 月 (2)
- 2015 年 12 月 (1)
- 2015 年 11 月 (3)
- 2015 年 9 月 (1)
- 2015 年 8 月 (2)
- 2015 年 7 月 (8)
- 2015 年 6 月 (5)
- 2015 年 5 月 (3)
- 2015 年 4 月 (4)
- 2015 年 3 月 (3)
- 2015 年 2 月 (1)
- 2015 年 1 月 (1)
- 2014 年 10 月 (1)
- 2014 年 9 月 (2)
- 2014 年 8 月 (3)
- 2014 年 7 月 (4)
- 2014 年 6 月 (1)
- 2014 年 5 月 (3)
- 2014 年 4 月 (15)
- 2014 年 3 月 (5)
- 2009 年 7 月 (1)
Tags
Newsletter
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Insert the contact form shortcode with the additional CSS class- "bloghoot-newsletter-section"

By signing up, you agree to the our terms and our Privacy Policy agreement.
发表回复
要发表评论,您必须先登录。