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";
  • 相关阅读:
    Arduino-串口函数Serial
    声之翼——超声波模块
    Arduino入门教程--课前准备--Arduino驱动安装及1.0 IDE菜单介绍
    光之触角——光敏电阻、光敏二极管、光敏三极管与光照发生器
    reactjs--父组件调用子组件的内部方法(转载)
    React怎么创建.babelrc文件
    第一课 矩阵的行图像与列图像(麻省理工公开课:线性代数)【转载】
    单片机引脚间状态传递(非转载)
    sublime text2卸载和重新安装(转载)
    C语言头文件怎么写?(转载)
  • 原文地址:https://www.cnblogs.com/Skate0rDie/p/10737320.html
Copyright © 2011-2022 走看看