原文来自:https://www.zixuephp.com
DEDECMS列表页实现文档按权重排序
打造最全的CMS类教程聚合!实现文档按权重排序(从小到大的顺序)方法.
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='';if($orderby=="senddate"||$orderby=="id"){$ordersql="orderbyarc.id$orderWay";}elseif($orderby=="hot"||$orderby=="click"){$ordersql="orderbyarc.click$orderWay";}elseif($orderby=="lastpost"){$ordersql="orderbyarc.lastpost$orderWay";}elseif($orderby=="weight"){$ordersql="orderbyarc.weight$orderWay";}else{$ordersql="orderbyarc.sortrank$orderWay";}
- //phpfensi.com
3,同样是这个文件,查找“if(ereg('hot|click|lastpost',$orderby))”改为:
if(ereg('hot|click|weight|lastpost',$orderby))
上面三个步骤,即可实现列表页内容按权重排序,越小越靠前.