百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>Ecshop教程> ecshop获取点击人气排行榜
分享文章到:

ecshop获取点击人气排行榜

发布时间:12/03 来源: 浏览: 关键词:

ecshop获取点击人气排行榜

两部分。index.php和lib_goods.php
关于涉及到index.dwt的,请将按销量排行的改为from = top_hots_all
 

index.php增加

$smarty->assign('top_hots_all',       get_top10_hot(0));           // 全部人气排行

 

/**

lib_goods.php lib库增加函数(children取得子类产品id)
* 调用当前人气排行榜
*按点击排列 i<10 显示10个
* @access  public
* @param   string  $cats   查询的分类
* @return  array
*/

function get_top10_hot($cats)
{
if (empty($cats))
{
  $children = '';
}
   else 
{
    $children =  "WHERE ".get_children($cats);
}
  $sql = 'SELECT * ' .
            ' FROM ' . $GLOBALS['ecs']->table('goods') .' g '.
            "  $children" .
            ' ORDER BY click_count DESC LIMIT 0 , 10';

    $hot = $GLOBALS['db']->getALL($sql);

    for ($i = 0; $i < 10; $i++)
    {
        $hot[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
                                    sub_str($hot[$i]['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $hot[$i]['goods_name'];/*$hot[$i]['goods_name'];*/
        $hot[$i]['url']        = build_uri('goods', array('gid' => $hot[$i]['goods_id']), $hot[$i]['goods_name']);
  $hot[$i]['name'] = $hot[$i]['goods_name'];

    }
    return $hot;
}

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

相关文章

共有7人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板