您的位置:首页 > 其它

dedecms下修改class文件支持文章列表按权重排序

2016-03-06 14:26 375 查看
在模版文件中,list标签或者是arclist标签中添加,orderby='weight' orderway='asc'(权重越小,就越靠前)
在include/arc.listview.class.php文件中找到:

//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
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";
}
在click后面添加‘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";
}

找到排序方式添加
else if($orderby=="weight") {
$ordersql = "  ORDER BY arc.weight $orderWay";
}
即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: