dede織夢技巧:教你徹底解決dede按權重排序的問題(轉)


dede排序對網站來說一直存在問題,默認是按照最新發布時間排序。這樣排序有個問題,一旦更新之后即被視為最新發布,於是原本做好的排序瞬間就亂了。

 

這種時候,按權重排序是個很好的選擇,但按權重排序到處存在BUG~。很多地方都缺少設置,要么是設定后完全不起作用,在百度和論壇找了很多帖子,都沒能完全解決問題。在做第二個網站的時候,終於把BUG修訂完全了。

 

要解決權重排序的問題,主要集中在以下幾個文件上:

 

/include/arc.freelist.class.php   自由列表對應的文件

 

/dede/templets/freelist_edit.htm 新增自由列表對應的文件

 

/dede/templets/freelist_add.htm  修改自由列表對應的文件

 

/include/arc.listview.class.php   list列表對應的文件

 

/include/taglib/arclist.lib.php   arclist列表對應的文件

 

修改的內容很簡單,按照以下步驟即可修正:

 

1、打開/include/arc.freelist.class.php, 找到以下代碼:

 

else if($orderby=="rand")

 

{

 

$ordersql = "  ORDER BY rand()";

 

}

 

在代碼下方插入以下代碼后保存:

 

else if($orderby=="weight")

 

{

 

$ordersql = " order by arc.weight asc";

 

}

 

2、打開/dede/templets/freelist_add.htm,找到以下代碼:

 

<td height="28" align="left">排列順序:

 

         <select name="orderby" id="orderby" style="width:120">

 

在代碼下方插入以下代碼,保存:

 

<option value="weight">權重值</option>

 

3、打開/dede/templets/freelist_edit.htm,找到以下代碼:

 

<?php

 

       echo "<option value=\"$orderby\" selected>{$sortarrs[$orderby]}</option>\r\n";

 

?>

 

在代碼下方插入以下代碼,保存:

 

<option value="weight">權重值</option>

 

4、打開/include/arc.listview.class.php,找到以下代碼:

 

else if($orderby=="lastpost")

 

{

 

      $ordersql = "  ORDER BY arc.lastpost $orderWay";

 

}

 

在代碼下方插入以下代碼:

 

else if($orderby=="weight")

 

{

 

$ordersql = " order by arc.weight asc";

 

}

 

找到以下代碼:

 

if(preg_match('/hot|click|lastpost|/', $orderby))

 

替換為以下代碼並保存:

 

if(preg_match('/hot|click|lastpost|weight/', $orderby))

 

5、打開/include/taglib/arclist.lib.php,找到以下說明文字:

 

//功能:增加按好評數和差評數調用

 

替換為以下代碼並保存:

 

else if($orderby == 'weight') $ordersql = "  ORDER BY arc.weight asc";

 

//功能:增加按好評數和差評數調用



修改這5個文件,即能解決權重排序的問題(根據權重從小到大排列),並使得自由列表中,也可以采用權重排序的方式生成列表。

 

調用例子:

 

{dede:arclist flag='a' limit='0,1' typeid='10' isweight='y' orderby='weight'}

 

        <a href="/z/al/index_12_1.html" target="_blank">

 

        <img src="[field:picname/]" width="300" height="168" alt="[field:shorttitle/]" style="border:1px solid "></a>

 

{/dede:arclist}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM