dedecms列表页实现文档按权重weight排序

dedecms列表页实现文档按权重weight排序

1、调用   {dede:list pagesize='12′ orderby='weight' isweight='Y' orderway='desc'}
2、dedecms列表页文章按权重排序无效问题,找到list解析文件include/ arc.listview.class.php,发现排序规则里面并没有按照weight排序的判断,于是乎修改程序加入排序规则,大概在771行,加入下面红色代码
 
//排序方式
  $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、//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
if(preg_match('/hot|click|lastpost|weight/', $orderby))
 
 

dede:arclist按权重排序的修改方法

再改一个地方:/include/taglib/ arclist.lib.php加入红色的语句;
//文档排序的方式
$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 == 'weight') $ordersql = "  ORDER BY arc.weight $orderWay";
else if($orderby == 'scores') $ordersql = "  ORDER BY arc.scores $orderWay";
//功能:增加按好评数和差评数调用
else if($orderby == 'goodpost') $ordersql = " order by arc.goodpost $orderWay";
else if($orderby == 'badpost') $ordersql = " order by arc.badpost $orderWay";
else if($orderby == 'rand') $ordersql = "  ORDER BY rand()";
else $ordersql = " ORDER BY arc.sortrank $orderWay"; 
2、
  大约在74 、75行找到:
 
      // arclist是否需要weight排序,默认为"N",如果需要排序则设置为"Y"
    $isweight = $ctag->GetAtt('isweight');
 
把这行修改为:
 
  $weight = $ctag->GetAtt('weight');
或者: 修改 170行 $isweight='N' 的值为Y
 
调用:
{dede:arclist typeid='32' pagesize='20' isweight='Y' orderby='weight' orderway='desc'}
orderby='weight' orderway='desc'  
备注 //desc 从大到小和asc 从小到大

转载于:https://www.cnblogs.com/wolflower/p/10721762.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值