zoukankan      html  css  js  c++  java
  • dedecms 文章根据 权重排序

    原文链接

    一: dede:list   标签

    找到 /include/arc.listview.class.php

    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";
            }
    if(preg_match('/hot|click|weight|lastpost/', $orderby)) // 新增
            {
                $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
               tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
               $addField
               FROM `#@__archives` arc
               LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id
               $addJoin
               WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row";
            }

    模板中  :

     orderby='weight' orderway='asc'

    二: dede:arclist  标签

    找到       include aglibarclist.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 == '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"; 

    插入下面这行代码:

         else if($orderby == 'weight') $ordersql = "  order by arc.weight asc";
  • 相关阅读:
    多表关联查询_resultMap_集合对象
    mybatis多表关联查询之resultMap单个对象
    十二.filter
    十二.函数式编程
    十一.列表生成式
    十,迭代
    九.高级特性
    八.函数
    七.条件判断和循环
    六.使用list和tuple
  • 原文地址:https://www.cnblogs.com/Skate0rDie/p/10737320.html
Copyright © 2011-2022 走看看