织梦dedecms列表页list标签weight权重排序方法
我们有时候需要对织梦列表页文档进行排序,最好的办法就是按照weight,因为这样比较灵活。需要怎么操作呢?
1、打开include/arc.listview.class.php,找到如下代码:
1、打开include/arc.listview.class.php,找到如下代码:
else if($orderby=="lastpost")
{
$ordersql = " ORDER BY arc.lastpost $orderWay";
}
替换成如下代码:
else if($orderby=="lastpost") {
$ordersql = " ORDER BY arc.lastpost $orderWay";
}
else if($orderby=="weight") {
$ordersql = " ORDER BY arc.weight $orderWay";
}
2、找到如下代码:
if(preg_match('/hot|click|lastpost/', $orderby))
替换为:
if(preg_match('/hot|click|lastpost|weight/', $orderby))
3、找到:
$query = "SELECT id FROM `dede_arctiny` arc WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row ";
替换为:
$query = "SELECT id FROM `dede_archives` arc WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row ";
5、标签调用:
{dede:list orderby='weight' orderway='asc' pagesize ='3'}
......
{/dede:list}
想要倒序或者正序调整orderway,接下来{dede:list}标签就支持了按权重排序的调用了。