EC商品的相册功能很好,可是要切换到大相册才能看见缩略的大图,所以找了一些改变这个相册的文章、写出来和大家分享!
第一步、用编辑器打开商品详情页模板文件-----goods.dwt,在<head></head>之间添加以下代码:
<script type="text/javascript"> function change_img(img_src) { document.getElementsByName("goods_img")[0].src=img_src; } </script>
然后定位到:(我在实际操作中这步省略了也可实现效果)
<img src="{$goods.goods_img}" alt="{$goods.goods_name|escape:html}" >
把它修改为:
<img src="{$goods.goods_img}" alt="{$goods.goods_name|escape:html}" name="goods_img" width="250" height="250"/>
第二步、用编辑器打开商品相册库文件-----goods_gallery.lbi 找到
<!-- {foreach from=$pictures item=picture}--> <li><a href="gallery.php?id={$id}&img={$picture.img_id}" target="_blank"><img src="{if $picture.thumb_url}{$picture.thumb_url}{else}{$picture.img_url}{/if}" alt="{$goods.goods_name}" class="B_blue" /></a> </li> <!--{/foreach}-->
改为:
<!-- {foreach from=$pictures item=picture}--> <li><a href="gallery.php?id={$id}&img={$picture.img_id}" target="_blank"><img src="{if $picture.thumb_url}{$picture.img_url}{else}{$picture.img_url}{/if}" alt="{$goods.goods_name}" class="B_blue" onmouseOver="change_img(this.src)" /></a></li> <!--{/foreach}-->