点击人气排行榜。。。。hacks by xoao.com

hacks by xoao.com

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

index.php增加

  1. $smarty->assign('top_hots_all',       get_top10_hot(0));           // 全部人气排行
  1. /**
  2.  
  3. lib_goods.php lib库增加函数(children取得子类产品id)
  4. * 调用当前人气排行榜
  5. *按点击排列 i<10 显示10个
  6. * @access  public
  7. * @param   string  $cats   查询的分类
  8. * @return  array
  9. */
  10.  
  11. function get_top10_hot($cats)
  12. {
  13. if (empty($cats))
  14. {
  15.   $children = '';
  16. }
  17.    else
  18. {
  19.     $children =  "WHERE ".get_children($cats);
  20. }
  21.   $sql = 'SELECT * ' .
  22.             ' FROM ' . $GLOBALS['ecs']->table('goods') .' g '.
  23.             "  $children" .
  24.             ' ORDER BY click_count DESC LIMIT 0 , 10';
  25.  
  26.     $hot = $GLOBALS['db']->getALL($sql);
  27.  
  28.     for ($i = 0; $i < 10; $i++)
  29.     {
  30.         $hot[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
  31.                                     sub_str($hot[$i]['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $hot[$i]['goods_name'];/*$hot[$i]['goods_name'];*/
  32.         $hot[$i]['url']        = build_uri('goods', array('gid' => $hot[$i]['goods_id']), $hot[$i]['goods_name']);
  33.   $hot[$i]['name'] = $hot[$i]['goods_name'];
  34.  
  35.     }
  36.     return $hot;
  37. }
如果你是第一次来这儿,欢迎订阅 feedsky RSS feed。 第一时间看到更多精彩内容,谢谢你的访问!
原文地址:http://my.xoao.com/top-order-by-click
转载请注明出处,非常感谢!
admin on 01月 20th, 2008 | File Under PHP | -