• 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 从小到大
  • 相关阅读:
    javamail.providers not found
    vue.js实现购物车功能2.0版本
    vue.js实现购物车功能
    iframe高度自适应
    C语言 自定义字符串拼接函数
    php安装
    Apache安装
    python:爬虫初体验
    c:forEach 显示下拉框并回显
    数据结构 --- 线性表学习(php模拟)
  • 原文地址:https://www.cnblogs.com/wolflower/p/10721762.html
Copyright © 2020-2023  润新知