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