dede列表頁權(quán)重排序:
根據(jù)權(quán)重排序dede_arctiny 按weight實(shí)現(xiàn)文檔按權(quán)重weight排序(從小到大的順序)方法:
1,在list_artcile.htm模板中使用
{dede:list pagesize=’12′ orderby=’weight’ orderway=’asc’}
2,然后修改include目錄下的arc.listview.class.php
查找else if($orderby==”lastpost。。。
在下面補(bǔ)充
else if($orderby==”weight”) { $ordersql = ” order by arc.weight $orderWay”; }
3,同樣是這個(gè)文件,查找“if(ereg(‘hot|click|lastpost’,$orderby))”改為:
if(ereg(‘hot|click|weight|lastpost’,$orderby))
上面三個(gè)步驟,即可實(shí)現(xiàn)列表頁內(nèi)容按權(quán)重排序,越小越靠前。
希望以上內(nèi)容對大家有所幫助。
首頁按照權(quán)重排序:
1、在織夢系統(tǒng)中找到以下目錄includetaglib中的arclist.lib.php文件并打開
大約在74 、75行找到:
// arclist是否需要weight排序,默認(rèn)為"N",如果需要排序則設(shè)置為"Y"
$isweight = $ctag->GetAtt('isweight');
把這行修改為:
$weight = $ctag->GetAtt('weight');
大約在327行找到
//文檔排序的方式
$ordersql = '';
if($orderby=='hot' || $orderby=='click') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
else if($orderby == 'id') $ordersql = " ORDER BY arc.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = " ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else $ordersql = " ORDER BY arc.sortrank $orderWay";
修改為:
//文檔排序的方式
$ordersql = '';
if($orderby=='hot' || $orderby=='click') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
else if($orderby == 'id') $ordersql = " ORDER BY arc.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = " ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else if($orderby == 'weight') $ordersql = " order by arc.weight asc";//如果沒有特定設(shè)置排序則按照權(quán)重先排序
else $ordersql = " ORDER BY arc.sortrank $orderWay";
OK 現(xiàn)在把這個(gè)文檔保存了 我們就可以在首頁使用 orderby='weight' 進(jìn)行排序了。
備注:按照大還是小排序,如下修改:
織夢dedecms有一個(gè)按權(quán)重排序功能,不過是按權(quán)重越小越靠前來排序的。由于文章它默認(rèn)權(quán)重跟ID相同,是越來越大的,所以有很多文章時(shí),我們按照越小越靠前是很不合理的,所以我們要把它權(quán)重改成越大越靠前。
方法:
1. 在includetaglibarclist.lib.php文件中,將 else if($orderby == 'weight') $ordersql = " order by arc.weight asc";//如果沒有特定設(shè)置排序則按照權(quán)重先排序
2.改成 else if($orderby == 'weight') $ordersql = " order by arc.weight desc";//如果沒有特定設(shè)置排序則按權(quán)重越大越靠前排序
轉(zhuǎn)發(fā)請注明:丁丁貓