有客户问到ecshop促销活动商品全部归类调用在一个列表下,有什么方法呢? 其实这个在ecshop已经有默认的函数存在,以下模板里的代码:
代码如:
<ul class=”tabcon”> <!– {foreach name=top_goods from=$top_goods item=goods}–> <!– {if $smarty.foreach.top_goods.iteration<2}–> <li class=”fore”><span><!– {$smarty.foreach.top_goods.iteration}–></span><div class=”p-img”><a target=”_blank” href=”{$goods.url}”><img src=”{$goods.thumb}” alt=”{$goods.name|escape:html}” height=”50″ width=”50″></a></div><div class=”p-name”><a href=”{$goods.url}” title=”{$goods.name|escape:html}”>{$goods.short_name}</a></div><div class=”p-price”><strong>{$goods.price}</strong></div></li> <!– {else} –> <li><span{if $smarty.foreach.top_goods.iteration>3} class=”bg1″{/if}><!– {$smarty.foreach.top_goods.iteration}–></span><div class=”p-name”><a href=”{$goods.url}” title=”{$goods.name|escape:html}”>{$goods.short_name}</a></div></li> <!– {/if} –> <!– {/foreach} –> </ul>
$top_goods,就是所有促销下商品的总调用函数
<!– {if $smarty.foreach.top_goods.iteration<2}–> 如果显示ID数量小于2.促销商品列表图文形式显示
{if $smarty.foreach.top_goods.iteration>3} 如果显示ID数量大于3,促销商品列表文章形式显示
以上代码还是有点用途, 可以在ecshop优化同时,让所有的促销活动,分布在全站页面。
