DedeCMS用于圖片站W(wǎng)EB開發(fā)時,需要隨機調(diào)用文章、圖集和關(guān)聯(lián)文章、圖集功能,以增加用戶黏度,屬于站內(nèi)優(yōu)化重要一部分。一般用標(biāo)簽調(diào)用都有排序orderby,默認的排序主要有
打開/include/taglib/likearticle.lib.php,找到
if( empty($arcid) || $byabs==0 ) {
$orderquery = " order by arc.id desc ";
}
else {
$orderquery = " order by ABS(arc.id - ".$arcid.") ";
}
修改為
if($orderby=='hot' || $orderby=='click') $orderquery = " order by arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $orderquery = " orderby arc.sortrank $orderWay";
else if($orderby == 'id') $orderquery = " order by arc.id $orderWay";
else if($orderby == 'near') $orderquery = " order by ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $orderquery = " order by arc.lastpost $orderWay";
else if($orderby == 'scores') $orderquery = " order by arc.scores $orderWay";
else if($orderby == 'rand') $orderquery = " order by rand()";
else if($orderby == 'weight') $orderquery = " order by arc.weight asc";//如果沒有特定設(shè)置排序則按照權(quán)重先排序
else $orderquery = " order by arc.sortrank $orderWay";
注意到排序是針對數(shù)字而言,因此只要這里就可以拓展成許多自定義排序,比如DedeCMS做商城時按照價格排序功能就可以這樣做。
在上面代碼最后一行前增加一行代碼
else if($orderby == 'trueprice') $ordersql = " order by addf.trueprice $orderWay";
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: dedecms中arclist、likearticle標(biāo)簽增加價格排序