织梦DedeCMS让{dede:list}标签支持weight权重排序、flag


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

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、再在第778行处找到此段代码

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

  并添加红色部分内容。

4、标签调用:

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

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


5、将文件中原有的这部分注释掉

//        if($this->TotalResult==-1)
//        {
//            $cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql;
//            $row = $this->dsql->GetOne($cquery);
//            if(is_array($row))
//            {
//                $this->TotalResult = $row["dd"];
//            }
//            else
//            {
//                $this->TotalResult = 0;
//            }
//        }

6、在238行左右  $this->dtp->LoadTemplate($tempfile);下添加如下代码:

    
        foreach($this->dtp->CTags as $tagid=>$ctag)
        {     
                $flag = $ctag->GetAtt("flag");
                if($flag!="") {
                $this->addSql .=  " and arc.flag like "%{$flag}%"";
                }
        }
        if($this->TotalResult==-1)
        {    //修改了
       
            $cquery = "SELECT COUNT(*) AS dd FROM `#@__archives` arc WHERE ".$this->addSql;
            $row = $this->dsql->GetOne($cquery);
         
            if(is_array($row))
            
                $this->TotalResult = $row["dd"]; 
            }
            else
            {
                $this->TotalResult = 0;
            }
           
        }
       

7、在647行左右$ctag->GetAtt("orderway"),下面添加一行:

      $ctag->GetAtt("flag")

8、在721行左右function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
   $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay="desc",$flag="")中添加了$flag=""

9、在754行左右也就是排序方式上面添加 :

   
        //添加flag标签
        $whereFlag = "";
        if($flag!="") {
            $whereFlag = " and arc.flag like "%{$flag}%"";
        }
       

10、在813行左右 修改成  if(preg_match("/hot|click|lastpost|weight|flag/", $orderby))

     接着在下面的$query  sql语句中WHERE {$this->addSql} 后面添加 {$whereFlag}

11、847行左右   $query sql语句中WHERE arc.id in($idstr)后面添加 {$whereFlag} 



flag属性就添加成功了


net65090.gif

你可能感兴趣的:(orderby,上面,loadtemplate,idstr)