dede5.6和5.7版本中实现dede:list按权重排序

文章介绍一、dedecms v5.6列表页标签{dede:list}增加按权重排序标签dedecms v5.6版本已经中已经添加权重字段,并且在{dede:arclist}标签中默认可以使用。但在列表页的标签 {dede:list}中是还是无法按权重实现排序。其实解决方法很简单,下面给出方法:1、打开\include\目录中的arc.listview.class.php文件,搜索“排序方式”,然后在else if($orderby=="lastpost"😉 {$ordersql = " order by arc.lastpost $orderWay";}else if($orderby == "weight"😉 {$ordersql = " order by arc.weight asc";}else {$ordersql=" order by arc.sortrank $orderWay";}这段代码中间添加以上红色代码。4、向下找到if(ereg('hot|click|lastpost',$orderby))或者是if(preg_match('/hot|click|lastpost/', $orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby))或者是if(preg_match('/hot|click|lastpost|weight/', $orderby)) ,保存文件。这个时候在列表页里就可以使用{dede:list pagesize='5' orderby='weight'} 进行排序了。二、DEDE 5.7 首页【arclist】增加按权重排序1、在织梦系统中找到以下目录\include\taglib中的arclist.lib.php文件并打开大约在74 、75行找到:// arclist是否需要weight排序,默认为"N",如果需要排序则设置为"Y"$isweight = $ctag->GetAtt('isweight'😉;把这行修改为:$weight = $ctag->GetAtt('weight'😉;大约在327行找到//文档排序的方式$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";OK 现在把这个文档保存了 我们就可以在首页使用 orderby='weight' 进行排序了。

注明:本文为星速云原创版权所有,禁止转载,一经发现将追究版权责任!

(0)
上一篇 2022年5月30日 上午3:59
下一篇 2022年5月30日 上午3:59

相关推荐

发表评论

登录后才能评论
问答社区 QQ客服
微信客服
微信客服
分享本页
返回顶部