發新話題
列印

點擊人氣排行榜

點擊人氣排行榜

有鑑於官方高手如雲,我們這裡似乎比較少去研究這些東西
就抓過來和大家分享吧,要看原始文章,最下面是有連結的
點擊人氣排行榜。。。。

兩部分。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;
}
原文
2.6版目前暫定不提供,因此有任何問題述本人無法回答,歡迎其他朋友幫忙解決,感恩
@@近期動態:近期回覆以一大早和晚上為主,努力作一些東西給大家用@@

TOP

(點上方按鈕開啟)億商互動售前諮詢MSN帳號為: [email protected] ,歡迎您詢問主機、金流、物流、維護服務上的問題
發新話題