織夢cms列表頁{dede:list}標籤實現按文章權重weight排序的方法

織夢cms列表頁{dede:list}標籤實現按文章權重weight排序的方法
下面就是織夢cms列表頁{dede:list}標籤實現按文章權重weight排序的方法:

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'}

按照以上方法,織夢dedecms列表頁{dede:list}標籤就支持了按權重排序的調用,並且動靜態狀態下測試均成功!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章