一: dede:list 标签
找到 /include/arc.listview.class.php
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";
}
if(preg_match('/hot|click|weight|lastpost/', $orderby)) // 新增
{
$query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
$addField
FROM `#@__archives` arc
LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id
$addJoin
WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row";
}
模板中 :
orderby='weight' orderway='asc'
二: dede:arclist 标签
找到 \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 == 'goodpost') $ordersql = " order by arc.goodpost $orderWay";
else if($orderby == 'badpost') $ordersql = " order by arc.badpost $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else $ordersql = " ORDER BY arc.sortrank $orderWay";
插入下面这行代码:
else if($orderby == 'weight') $ordersql = " order by arc.weight asc";