广告投放

ecshop商城首页增加一个商品浏览排行榜(教程)

目录

    ecshop商城首页增加一个商品浏览排行榜浏览排行榜,并且可以在商城后台的“模板设置”里进行控制

    由于ECSHOP商城默认是没有读取浏览排行的,所以这部分功能既得修改程序,又得增加模板。
    以 ecshop官方默认模板为例进行修改,如果是其他模板css自行增加。

    ecshop商城首页增加一个商品浏览排行榜(教程)

    商城首页效果图:

    ecshop商城首页增加一个商品浏览排行榜(教程)

    一、将下面代码复制并保存到 一个新文件中,文件路径为: /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>

    二、修改 /includes/lib_goods.php 文件,在最后前面?>增加一个函数

    /**
     * 增加调用商品浏览排行榜
     *
     * @ecshop119.com
     * 
     */
    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;
    }
     

    三、在网站根目录打开  /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 -->

    五、打开 /admin/includes/lib_template.php 查找

    '/library/invoice_query.lbi' => 0,

    在上面添加代码

    '/library/top10_click.lbi' => 0,

    六、继续修改语言包文件 /languages/zh_cn/admin/template.php 查找

    $_LANG['template_libs']['top10'] = '销售排行';

    在下面添加代码

    $_LANG['template_libs']['top10_click'] = '浏览排行';

    七、修改 /themes/default/lib.xml 查找

    <lib>top10</lib>

    在下面添加代码

    <lib>top10_click</lib>
    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

    给TA打赏
    共{{data.count}}人
    人已打赏
    广告位招租919838898
    0 条回复 A文章作者 M管理员
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    有新私信 私信列表
    搜索