ECSHOP教程:
全部
ECSHOP下载
ECSHOP安装教程
ECSHOP使用教程
ECSHOP二次开发
ECSHOP模板教程
ECSHOP微信商城
ECSHOP支付方式配置教程
ECSHOP操作手册
在ECSHOP首页增加一个商品浏览排行榜
1)、将下面代码复制并保存到 一个新文件中,文件路径为: /themes/default/library/top10_click.lbi
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div class="box"> <div class="box_2"> <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> |
2)、修改 /includes/lib_goods.php 文件
在最下面增加一个函数
/** * 调用浏览排行榜 * * @access public * @return array */ 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; } |
3)、修改 /index.php 文件
在
$smarty->assign('top_goods', get_top10()); // 销售排行 |
下面另起一行增加
$smarty->assign('top_goods_click', get_top10_click()); // 浏览排行 |
修改模板文件 /themes/default/index.dwt
找到
<!-- #BeginLibraryItem "/library/promotion_info.lbi" --> |
<!-- #BeginLibraryItem "/library/top10_click.lbi" --><!-- #EndLibraryItem --> |
4)、修改 /admin/includes/lib_template.php 文件
在
'/library/invoice_query.lbi' => 0, |
上边增加一行代码
'/library/top10_click.lbi' => 0, |
5)、继续修改语言包文件 /languages/zh_cn/admin/template.php
在
$_LANG['template_libs']['top10'] = '销售排行'; |
下边增加一行代码
$_LANG['template_libs']['top10_click'] = '浏览排行'; |
6)、修改 /themes/default/lib.xml 文件
找到
<lib>top10</lib> |
并且在它下面另起一行,增加
<lib>top10_click</lib> |
7)、最后进入 后台 》模板管理 》设置模板, 是不是看到了期待已久的“浏览排行”,设置一下,并清除缓存,就OK了
转载请注明:ecshop插件网-ecshop插件网官网http://www.ecshop520.com/jiaocheng-400.html
- 下一篇: :ECSHOP首页主导航栏下面增加显示热门关键词搜索
- 上一篇: 怎么样让ECSHOP商品在弹出新窗口打开