1. 程式人生 > >織夢文檔按權重排序

織夢文檔按權重排序

插入 測試 .class dir () 查詢 pos reg cores

dede:list 的方法

1、找到"根目錄\include\arc.listview.class.php"文件。

2、修改代碼:在文件第727行處添加按weight排序判斷代碼(紅色部分為新添加代碼)。

//排序方式
$ordersql = ‘‘;
if($orderby=="senddate" || $orderby=="id") {
$ordersql=" ORDER BY arc.id $orderWay";
}
else if($orderby=="hot" || $orderby=="click") {
$ordersql = " ORDER BY arc.click $orderWay";

}
else if($orderby=="lastpost") {
$ordersql = " ORDER BY arc.lastpost $orderWay";
}
else if($orderby=="weight") {
$ordersql = " ORDER BY arc.weight $orderWay";
}
else {
$ordersql=" ORDER BY arc.sortrank $orderWay";
}

3、再在第778行處找到此段代碼

  //如果不用默認的sortrank或id排序,使用聯合查詢(數據量大時非常緩慢)
  if(preg_match(‘/hot|click|lastpost|weight/‘, $orderby))

  並添加紅色部分內容。

4、標簽調用:

  {dede:list orderby=‘weight‘ orderway=‘asc‘}

  這樣{dede:list}標簽就支持了按權重排序的調用,並且動靜態狀態下測試均成功!

下面是dede:arclist的修改方法

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

大約在74 、75行找到:

// arclist是否需要weight排序,默認為"N",如果需要排序則設置為"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 if($orderby == ‘weight‘) $ordersql = " order by arc.weight asc";//插入這句 從小到大

else $ordersql = " ORDER BY arc.sortrank $orderWay";

然後用orderby=‘weight‘

織夢文檔按權重排序