zoukankan      html  css  js  c++  java
  • dede:list及dede:arclist 按权重排序的方法

    有时我们需要做文章排名,比如指定第一名到第三名在前面,这样就用到这个权重排序方法。稍改下就可以完美支持。。

    dede:list 的方法

    1. 1

      找到"根目录includearc.listview.class.php"文件。

    2. 2

      修改代码:在文件第727行处添加按weight排序判断代码(红色部分为新添加代码)。

       //排序方式$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. 3

      再在第778行处找到此段代码

        //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)     if(preg_match('/hot|click|lastpost|weight/', $orderby))

        并添加红色部分内容。

    4. 4

      标签调用:

        {dede:list orderby='weight' orderway='asc'}

        这样{dede:list}标签就支持了按权重排序的调用,并且动静态状态下测试均成功!

      END

    dede:arclist的修改方法

    1

    在织梦系统中找到以下目录include aglib中的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 if($orderby == 'weight') $ordersql = "  order by arc.weight asc";//插入这句 从小到大

        else $ordersql = " ORDER BY arc.sortrank $orderWay";

     

    然后用orderby='weight'

  • 相关阅读:
    leetcode 86. Partition List
    leetcode 303. Range Sum Query
    leetcode 1310. XOR Queries of a Subarray
    leetcode 1309. Decrypt String from Alphabet to Integer Mapping
    leetcode 215. Kth Largest Element in an Array
    将numpy.ndarray写入excel
    leetcode 1021 Remove Outermost Parentheses
    leetcode 1306. Jump Game III
    leetcode 1305. All Elements in Two Binary Search Trees
    ICCV2019 oral:Wavelet Domain Style Transfer for an Effective Perception-distortion Tradeoff in Single Image Super-Resolution
  • 原文地址:https://www.cnblogs.com/lxwphp/p/7731167.html
Copyright © 2011-2022 走看看