dede:list和dede:arclist列表按權重排序修改方法[織夢網站模板使用教程]

閱讀 ?·? 發布日期 2019-05-27 07:22 ?·? admin

dede:list和dede:arclist列表按權重排序修改方法[織夢網站模板使用教程]有時候客戶需要某幾篇文章按照自己的意思排列順序,就要用到按權重排序,下面介紹織夢dedecms的dede:list和dede:arclist列表按權重排序修改方法。

倒序 orderway='asc'

orderway是設置排序的方式,值為desc和asc

dedecms列表頁實現文檔按權重weight排序

1,在list_artcile.htm模板中使用

{dede:list pagesize='12′ orderby='weight' orderway='desc'}

2,然后修改include目錄下的arc.listview.class.php

查找else if($orderby=="lastpost") { $ordersql = "  ORDER BY arc.lastpost $orderWay";} , dedecms5.7sp2大概在768行

在下面補充

else if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; }

3,同樣是這個文件,

查找“if(preg_match('/hot|click|lastpost/', $orderby))”

改為:

if(preg_match('/hot|click|weight|lastpost/', $orderby))

上面三個步驟,即可實現列表頁內容按權重排序,越小越靠前。僅限dedecms v5.7 SP2測試!


dede:arclist按權重排序的修改方法

1、在織夢系統中找到以下目錄\include\taglib中的arclist.lib.php文件并打開

大約在74 、75行找到:

// arclist是否需要weight排序,默認為"N",如果需要排序則設置為"Y"

$isweight = $ctag->GetAtt('isweight');

把這行修改為:

$weight = $ctag->GetAtt('weight');

或者修改了 170行 $isweight='N' 的值為Y

大約在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 == 'weight') $ordersql = "  order by arc.weight $orderWay";   //主要是這一句,應該是這一句就夠了,需要修改的小伙伴,試一下只改這里,上面綠色文字不改看看是不是也可以的

調用方法:orderby='weight'  orderway='desc'   //desc和asc