有客戶問到ecshop促銷活動商品全部歸類調(diào)用在一個列表下,有什么方法呢? 其實這個在ecshop已經(jīng)有默認(rèn)的函數(shù)存在,以下模板里的代碼:
代碼如:
<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,就是所有促銷下商品的總調(diào)用函數(shù)
<!-- {if $smarty.foreach.top_goods.iteration<2}--> 如果顯示ID數(shù)量小于2.促銷商品列表圖文形式顯示
{if $smarty.foreach.top_goods.iteration>3} 如果顯示ID數(shù)量大于3,促銷商品列表文章形式顯示
以上代碼還是有點用途, 可以在ecshop優(yōu)化同時,讓所有的促銷活動,分布在全站頁面。
新聞熱點
疑難解答
圖片精選