青岛网站建设新闻资讯

在ECSHOP首页增加一个浏览排行

时间:2012-08-18 已阅读:686次 | 作者:青岛网站建设

首页>新闻资讯>建站知识

最近有看到朋友在ECSHOP论坛里提问: 如何在首页增加一个类似于“销售排行榜”的“浏览排行榜”,并且可以在后台的“模板设置”里进行控制。

由于系统默认是没有读取浏览排行的,所以这部分功能既得增加程序,又得增加模板。
本教程是以 ecshop2.7.2 官方默认模板 为例进行讲解的。

效果图如下:


1)、将下面代码复制并保存到 一个新文件中,文件路径为: /themes/default/library/top10_click.lbi



 

  

浏览排行


 

 
 

     
     
         

  •       {$goods.name|escape:html}
         

  •    
         

  •       {$goods.short_name}

          {$lang.shop_price}{$goods.price}

         

  •    

 
 

 



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
找到
在它的前面增加


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 文件

找到 top10
并且在它下面另起一行,增加 top10_click
 7)、最后进入 后台 》模板管理 》设置模板, 是不是看到了期待已久的“浏览排行”,设置一下,并清除缓存,就OK了


二维码
扫描二维码手机查看该文章

文章引用:https://www.qinghuahulian.com/news/webzhishi/153.html

相关资讯

Copyright © 2011-2024 青华互联-青岛青华锐思网络科技有限公司 www.qinghuahulian.com All Rights Reserved
鲁公网安备37020202000800号 鲁ICP备14020555号-4 网站地图 百度地图