dedecms教程:让{dede:list}标签支持weight权重排序

2017-04-13 14:27:04 dedecms

打开include/arc.listview.class.php文件

1、找到如下代码(约727行):

//排序方式

$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 {

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

}

修改为:

//排序方式

$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";

}

2、找到如下代码(约775行):

//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)

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

修改为:

//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)

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

标签调用:

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

这样{dede:list}就支持按权重排序调用了!