为ECSHOP增加一个浏览排行
2013-07-09 10:25
309 查看
因为公司一个电子商城用的是ECSHOP,为了对其2次开发,利用空余时间学习了有关知识。项目中经常会对客户产生的某个动作,我们根据这一动作进行排序。今天根据用户的浏览商品的次数,来为商城首页增加一个浏览排行。
第一步:增加一个浏览排行的页面,在themes/default/library下增加top10_click.lbi
内容如下:
显示模板:在themes/default/index.dwt中增加
第二步:读取用户浏览商品次数前10在includes/lib_goods.php增加get_top10_click()函数
为了使其lbi文件能够正常加载数据,在首页index.php文件中增加:
第三步:前端正常显示了,为了方便以后操作,在后端模板增加浏览排行,在admin/includes/lib_template.php中'index' => array()数组下增加
在语言包文件(languages/zh_ch/admin/template.php)中增加
在themes/default/libs.xml下<file name="index.dwt"></file>之间增加
大功告成,清空缓存,后台模块设置中有浏览排行这个模块了。
第一步:增加一个浏览排行的页面,在themes/default/library下增加top10_click.lbi
内容如下:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div class="box"> <div class="box_2"> <!--<div class="top10Tit"></div>--> <h3><span>浏览排行</span></h3> <div class="top10List clearfix"> <!-- {foreach name=top_goods from=$top_goods_click item=goods}--> <ul class="clearfix"> <img src="../images/top_{$smarty.foreach.top_goods.iteration}.gif" class="iteration" /> <!-- {if $smarty.foreach.top_goods.iteration<4}--> <li class="topimg"> <a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="samllimg" /></a> </li> <!-- {/if} --> <li {if $smarty.foreach.top_goods.iteration<4}class="iteration1"{/if}> <a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name}</a><br /> {$lang.shop_price}<font class="f1">{$goods.price}</font><br /> </li> </ul> <!-- {/foreach} --> </div> </div> </div> <div class="blank5"></div>
显示模板:在themes/default/index.dwt中增加
<!-- #BeginLibraryItem "/library/top10_click.lbi" --><!-- #EndLibraryItem -->
第二步:读取用户浏览商品次数前10在includes/lib_goods.php增加get_top10_click()函数
function get_top10_click() { $sql = "SELECT goods_id,goods_name,shop_price,goods_thumb FROM".$GLOBALS['ecs'] -> table('goods')." where is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 ORDER by click_count desc LIMIT 10"; $arr = $GLOBALS['db'] -> getAll($sql); for($i = 0,$count = count($arr);$i < $count;$i++){ $arr[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0?sub_str($arr[$i]['goods_name'],$GLOBALS['_CFG']['goods_name_length']) :$arr[$i]['goods_name']; $arr[$i]['url']= build_uri('goods', array('gid' => $arr[$i]['goods_id']), $arr[$i]['goods_name']); $arr[$i]['thumb'] = get_image_path($arr[$i]['goods_id'], $arr[$i]['goods_thumb'],true); $arr[$i]['price'] = price_format($arr[$i]['shop_price']); } return $arr; }
为了使其lbi文件能够正常加载数据,在首页index.php文件中增加:
$smarty->assign('top_goods_click',get_top10_click());//浏览排行
第三步:前端正常显示了,为了方便以后操作,在后端模板增加浏览排行,在admin/includes/lib_template.php中'index' => array()数组下增加
'/library/top10_click.lbi' => 0,
在语言包文件(languages/zh_ch/admin/template.php)中增加
$_LANG['template_libs']['top10_click'] = '浏览排行';
在themes/default/libs.xml下<file name="index.dwt"></file>之间增加
<lib>top10_click</lib>
大功告成,清空缓存,后台模块设置中有浏览排行这个模块了。
相关文章推荐
- 在ECSHOP首页增加一个浏览排行
- ECSHOP首页增加一个浏览排行
- 在ECSHOP首页增加一个浏览排行
- ecshop给文章页增加一个浏览次数
- 【转】Ecshop 后台增加一个左侧列表菜单menu菜单的方法
- [ecshop 资料] ecshop 会员增加字段 msn地址不是一个有效的邮件地址 68ecshop
- ECSHOP二次开发--给商品增加一个新字段 另法
- ECshop循环中获取一个会自动增加的数字
- 非常不错的 ecshop增加 浏览过该商品的人还浏览了那些商品 功能
- ecshop商品列表页面增加按销量排行
- ecshop增加一个后台菜单
- Ecshop 后台增加一个左侧列表菜单menu菜单的方法
- Ecshop商品新增加一个图片上传功能
- 在ecshop循环中获取一个会自动增加的数
- Ecshop 后台增加一个左侧列表菜单menu菜单的方法
- Ecshop 后台增加一个左侧列…
- ECSHOP二次开发--给商品增加一个新字段
- 今天周末,在家休息,从CString派生,写了个CExtendString类,增加了一个Splite函数用于分拆字符串。
- C# 给枚举类型增加一个备注特性
- 为取出的每个数组中增加一个自增的id(注意此ID不是数据库中存的自增id字段)