算是一次整理吧。
版权不属于本人,本人只是从论坛上学习,修改,甚至是照抄。
大家权当是我整理,方便大家查找吧。
演示网站:http://www.shexam.cn (认为我做广告的就不要点啦,代码绝对能用的,我就是这么改的)
1、“浏览历史” 改为图文显示:
修改文件:wwwroot\includes\lib_insert.php
/**
* 调用浏览历史
*
* @access public
* @return string
*/
function insert_history()
{
$str = ”;
if (!empty($_COOKIE[‘ECS’][‘history’]))
{
$where = db_create_in($_COOKIE[‘ECS’][‘history’], ‘goods_id’);
$sql = ‘SELECT goods_id, goods_name, goods_thumb FROM ‘ . $GLOBALS[‘ecs’]->table(‘goods’) .
” WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0″;
$query = $GLOBALS[‘db’]->query($sql);
$res = array();
while ($row = $GLOBALS[‘db’]->fetch_array($query))
{
$res[$row[‘goods_id’]] = $row;
}
$tureorder = explode(‘,’, $_COOKIE[‘ECS’][‘history’]);
foreach ($tureorder AS $key => $val)
{
$goods_name = htmlspecialchars($res[$val][‘goods_name’]);
$goods_thumb = htmlspecialchars($res[$val][‘goods_thumb’]);
if ($goods_name)
{
$short_name = $GLOBALS[‘_CFG’][‘goods_name_length’] > 0 ? sub_str($goods_name, $GLOBALS[‘_CFG’][‘goods_name_length’]) : $goods_name;
$str .= ‘<li><a href=”‘ . build_uri(‘goods’, array(‘gid’ => $val), $goods_name). ‘” title=”‘ . $goods_name . ‘”><img src=”‘.$goods_thumb.'”height=”150″><br>’. $short_name . ‘</a></li>’;
}
}
}
return $str;
}
用这一段替换掉原有的“调用浏览历史”这段代码。(这个代码怎么找知道吧?直接搜索“调用浏览历史”
代码中的”height=”150″是图片大小调整,大家自己看喜欢啦。
2、“销售排行榜” 改为 以图文形式排列
修改文件:模板文件夹\library\top10.lib
将所有代码替换成下面的
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<div>
<div>
<div></div>
<div>
<ul>
<!– {foreach name=top_goods from=$top_goods item=goods}–>
<li><img src=”../images/top_{$smarty.foreach.top_goods.iteration}.gif” /> <a href=”{$goods.url}” title=”{$goods.name|escape:html}”><img src=”{$goods.goods_img}” width=”100″ height=”100″ alt=”{$goods.short_name}” /></br>{$goods.short_name}</a></li>
<!–{/foreach}–>
</ul>
</div>
</div>
</div>
<div></div>
3、相同属性关联 改为 图片显示,并且移到商品详情页下面(原来在左侧,文字显示)
第一步:修改文件:模板文件夹\library\goods_attrlinked.lbi
将所有代码替换成下面的
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<!– 开始循环属性关联的商品 {foreach from=$attribute_linked item=linked}–>
<!– {if $linked.goods} –>
<div>
<div>
<h3><span>{$linked.title}</span></h3>
<div>
<!– {foreach from=$linked.goods item=linked_goods_data} –>
<div>
<a href=”{$linked_goods_data.url}”><img src=”{$linked_goods_data.goods_img}” alt=”{$linked_goods_data.short_name}” /></a><br />
<!– {if $show_marketprice} –>
{$lang.market_prices}<font>{$linked_goods_data.market_price}</font><br />
<!– {/if} –>
<!–{if $linked_goods_data.promote_price neq “” } –>
{$lang.promote_price}<font>{$linked_goods_data.promote_price}</font><br />
<!–{else}–>
{$lang.shop_prices}<font>{$linked_goods_data.shop_price}</font><br />
<!–{/if}–>
</div>
<!– {/foreach} –>
</div>
</div>
</div>
<div></div>
<!– {/if} –>
<!– 结束属性关联的商品 {/foreach}–>
第二步:修改模板下文件:goods.dwt
查找“ <!– #BeginLibraryItem “/library/goods_attrlinked.lbi” –>”
把”<!– #BeginLibraryItem “/library/goods_attrlinked.lbi” –>”和<!– 结束属性关联的商品 {/foreach}–>
<!– #EndLibraryItem –> 之间的代码全部删除
查找 <!– TemplateBeginEditable name=”右边可编辑区域” –>,
在后面添加
<!– 开始循环属性关联的商品 {foreach from=$attribute_linked item=linked}–>
<!– {if $linked.goods} –>
<h3><span title=”{$linked.title}”>{$linked.title}</span></h3>
<ul>
<!– {foreach from=$linked.goods item=linked_goods_data} –>
<li>
<div><a href=”{$linked_goods_data.url}”><img src=”{$linked_goods_data.goods_img}” alt=”{$linked_goods_data.short_name}” /></a><br />
<!– {if $show_marketprice} –>
{$lang.market_prices}<font>{$linked_goods_data.market_price}</font><br />
<!– {/if} –>
<!–{if $linked_goods_data.promote_price neq “” } –>
{$lang.promote_price}<font>{$linked_goods_data.promote_price}</font><br />
<!–{else}–>
{$lang.shop_prices}<font>{$linked_goods_data.shop_price}</font><br />
<!–{/if}–>
</li>
<!– {/foreach} –>
</ul>
<div></div>
<!– {/if} –>
<!– 结束属性关联的商品 {/foreach}–>
4、在商品列表上面添加品牌分类,以便直接通过点击商品品牌快速查找本分类下商品,这个功能我认为很重要啊,不知道大家感想如何呢?想了解效果的可以进入上面演示网站瞧瞧。
修改文件:模板文件夹\category.dwt
查找<!– TemplateBeginEditable name=”右边区域” –>,在其下面添加:
<div>
<h3><span>按出版社分类迅速查看</span></h3>
<div>
<!– {if $brand_list} –>
<!– {foreach from=$brand_list item=brand name=”brand_foreach”} –>
<!– {if $brand.brand_logo} –>
<a href=”{$brand.url}”><img src=”data/brandlogo/{$brand.brand_logo}” alt=”{$brand.brand_name|escape:html} ({$brand.goods_num})” /></a>
<!– {else} –>
<div style=”white-space:nowrap; padding-left:{$cat.level*2}em;
{if $cat.has_children eq 0}float:left;padding-left: 1em;{else}clear:both;font-weight:bold;padding-top: 10px;{/if}
“>
<a href=”{$brand.url}”>{$brand.brand_name|escape:html} {if $brand.goods_num}{/if}</a>
</div>
<!– {/if} –>
<!– {/foreach} –>
<!– {/if} –>
</div>
</div>
5、在商品详情页添加折扣和节省
修改includes\lib_goods.php 文件,在(即注释“/* 获得商品的销售价格 ”)后面添加:
$row[‘sheng_price’] = $row[‘market_price’]-$row[‘shop_price’];
$row[‘zhekou_price’] = round(($row[‘shop_price’]/$row[‘market_price’])*100)/10+””;
$row[‘cuxiao_sheng_price’] = $row[‘market_price’]-$row[‘promote_price’];
$row[‘cuxiao_zhekou_price’] = round(($row[‘promote_price’]/$row[‘market_price’])*100)/10+””;
(想要在商品详情页添加促销价的折扣和节省的自己再如法炮制一段添加其后就可以了,以前网友弄的这个显示出来6折显示60折,不符合生活习惯,所以我就在后面除以十了,这样就符合现代规范)
到goods.dwt中找到市场价和促销价那一栏后面添加(当然你想添加什么地方都可以,看你自己感觉怎么美观了):
折扣:{$goods.zhekou_price} 折 节省:{$goods.sheng_price} 元
促销期间折扣:{$goods.cuxiao_zhekou_price} 折 节省:{$goods.cuxiao_sheng_price} 元
搞了这么多,大都是收集整理摸索的。
还有一个地方不会修改,有会的请大家不吝赐教啊
就是“全部品牌”(http://www.shexam.cn/brand.php)不想点的就把前面的域名换成自己的看下。
这个下面的品牌为什么没有链接呢?如果可以点击对应品牌,就能出来所以该品牌下的产品呢?
有会的请大家帮忙,谢谢了。

1 评论