dede文章列表如何按权重自定义排序

这个dede5.7默认的权重标签orderby='weight'使用了 ,dede:arclist标签中使用orderby='weight'来排序时并不起作用。那问题出在哪里呢?

我们include\taglib下找到文件arclist.lib.php  ,在代码的第74-75行,我们发现$isweight默认为N,所以我们在使用orderby='weight' 时需要在前面加上 isweight="Y" 来开启权重的使用。也可以加上orderway='asc'或orderway='desc'来限定排序的方式是升序还是降序

 

注:1、织梦5.7版本好像不用改了,直接用代码就可以按照权重来排序了,大家可以先不修改模板,直接引用试试,不行的话再修改。
2、如果在首页需要按权重排序,有的时候还需要把下面代码改一下:

大约在340行上面找到

//文档排序的方式

$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 == 'rand') $ordersql = " ORDER BY rand()";

else $ordersql = " ORDER BY arc.sortrank $orderWay";

修改为:

//文档排序的方式

$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 == 'rand') $ordersql = " ORDER BY rand()";

else if($orderby == 'weight') $ordersql = " order by arc.weight asc";//如果没有特定设置排序则按照权重先排序

else $ordersql = " ORDER BY arc.sortrank $orderWay";

主要是添加了红色部分

调用代码:{dede:arclist typeid='12' row='8' isweight='Y' orderby='weight' orderway='asc'}

默认是权重数字越小 越靠前 ,我们还可以修改成数字越大越靠前 方法如下

http://down.chinaz.com/try/201106/673_1.htm

文章列表页的标签dede:list还是无法按权限排序。这是因为dede:list标签并为加入按weight排序的方法。我们在include下面找到arc.listview.class.php打开

几个代码段

else if($orderby == "weight") {

$ordersql = " order by arc.weight $orderWay";

}

{dede:list pagesize='20' isweight='Y' orderby='weight' orderway='asc'}

 

详细见https://jingyan.baidu.com/article/93f9803f0efb98e0e46f552c.html

下载说明: 帮助教程
1.资源失效请联系QQ:1138166071补发;寻课加QQ联系
2.资源均为网络收集,仅供参考研究,请在下载后24小时内删除。不要商用和非法用途,否则后果自己承担。
3.默认解压密码:blog.qdql.net
4.购买本站资源即代表同意本站免责协议
5.提示:本站资源属虚拟商品,购买后恕不退款。
6.特别声明本站资源部分来源于网络,如有侵权,请联系站长进行删除处理!
本文地址:http://blog.qdql.net/3929/

发表评论


表情