DEDECMS列表页文档按权重排序的实现方法
本文实例讲述了DEDECMS列表页文档按权重排序的实现方法。分享给大家供大家参考。具体实现方法如下:
1、在list_artcile.htm模板中使用:
复制代码
代码如下:
{dede:list pagesize='12' orderby='weight' orderway='asc'}
2、然后修改include目录下的arc.listview.class.php,查找else if($orderby=="lastpost。。。在下面补充
复制代码
代码如下:
else if($orderby=="weight") {
$ordersql = " order by arc.weight $orderWay";
}
$ordersql = " order by arc.weight $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";
}
$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、同样是这个文件,查找“if(ereg('hot|click|lastpost',$orderby))”改为:
复制代码
代码如下:
if(ereg('hot|click|weight|lastpost',$orderby))
上面三个步骤,即可实现列表页内容按权重排序,越小越靠前.
希望本文所述对大家的dedecms二次开发有所帮助。