1. DedeCMS讓{dede:list}標簽支持weight權重排序

      2012-03-17

      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}標簽就支持了按權重排序的調用,并且動靜態狀態下測試均成功!