以官方自带默认模板为例进行修改,其他模板大同小异,可参照修改方法。
第一步、 用编辑器打开商品详情页模板文件-----goods.dwt
1. ----在之间加入如下代码
<script type="text/javascript">
function change_img(img_src)
{
document.getElementsByName("goods_img")[0].src=img_src;
}
</script>
2. ----定位到
<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" />
3. ----保存
第二步、 用编辑器打开商品相册库文件-----library/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}-->