DedeCMS让{dede:list}标签支持weight权重排序

/ 0评 / 1

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}标签就支持了按权重排序的调用,并且动静态状态下测试均成功!

发表评论

邮箱地址不会被公开。 必填项已用*标注