龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

解決織夢(mèng) dede:arclist中orderby=weight 按權(quán)重排序

2015.09.10 | 563閱讀 | 0條評(píng)論 | 未命名

一、dedecms v5.6列表頁標(biāo)簽{dede:list增加按權(quán)重排序標(biāo)簽

dedecms v5.6版本已經(jīng)中已經(jīng)添加權(quán)重字段,并且在{dede:arclist標(biāo)簽中默認(rèn)可以使用。但在列表頁的標(biāo)簽 {dede:list中是還是無法按權(quán)重實(shí)現(xiàn)排序。 解決方法: 1、打開\include\目錄中的arc.listview.class.php文件,搜索“排序方式”,然后在
  1. else?if($orderby=="lastpost")?{
  2. $ordersql?=?"?order?by?arc.lastpost?$orderWay";
  3. }
這段代碼和
  1. else?{
  2. $ordersql="?order?by?arc.sortrank?$orderWay";
  3. }
這段代碼中間粘貼上
  1. else?if($orderby?==?'weight')?$ordersql?=?"?order?by?arc.weight?asc";
2、找到if(ereg('hot|click|lastpost',$orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby))?,保存文件。 這個(gè)時(shí)候在列表頁里就可以使用{dede:list pagesize='5' orderby='weight'}?進(jìn)行排序了。

二、DEDE 5.7 首頁【arclist】增加按權(quán)重排序

1、在織夢(mèng)系統(tǒng)中找到以下目錄\include\taglib中的arclist.lib.php文件并打開 大約在74 、75行找到: // arclist是否需要weight排序,默認(rèn)為"N",如果需要排序則設(shè)置為"Y" $isweight = $ctag->GetAtt('isweight'); 把這行修改為: $weight = $ctag->GetAtt('weight'); 大約在327行找到
  1. //文檔排序的方式
  2. $ordersql?=?'';
  3. if($orderby=='hot'?||?$orderby=='click')?$ordersql?=?"?ORDER?BY?arc.click?$orderWay";
  4. else?if($orderby?==?'sortrank'?||?$orderby=='pubdate')?$ordersql?=?"?ORDER?BY?arc.sortrank?$orderWay";
  5. else?if($orderby?==?'id')?$ordersql?=?"?ORDER?BY?arc.id?$orderWay";
  6. else?if($orderby?==?'near')?$ordersql?=?"?ORDER?BY?ABS(arc.id?-?".$arcid.")";
  7. else?if($orderby?==?'lastpost')?$ordersql?=?"?ORDER?BY?arc.lastpost?$orderWay";
  8. else?if($orderby?==?'scores')?$ordersql?=?"?ORDER?BY?arc.scores?$orderWay";
  9. else?if($orderby?==?'rand')?$ordersql?=?"?ORDER?BY?rand()";
  10. else?$ordersql?=?"?ORDER?BY?arc.sortrank?$orderWay";
修改為:
  1. //文檔排序的方式
  2. $ordersql?=?'';
  3. if($orderby=='hot'?||?$orderby=='click')?$ordersql?=?"?ORDER?BY?arc.click?$orderWay";
  4. else?if($orderby?==?'sortrank'?||?$orderby=='pubdate')?$ordersql?=?"?ORDER?BY?arc.sortrank?$orderWay";
  5. else?if($orderby?==?'id')?$ordersql?=?"?ORDER?BY?arc.id?$orderWay";
  6. else?if($orderby?==?'near')?$ordersql?=?"?ORDER?BY?ABS(arc.id?-?".$arcid.")";
  7. else?if($orderby?==?'lastpost')?$ordersql?=?"?ORDER?BY?arc.lastpost?$orderWay";
  8. else?if($orderby?==?'scores')?$ordersql?=?"?ORDER?BY?arc.scores?$orderWay";
  9. else?if($orderby?==?'rand')?$ordersql?=?"?ORDER?BY?rand()";
  10. else?if($orderby?==?'weight')?$ordersql?=?"?order?by?arc.weight?asc";//如果沒有特定設(shè)置排序則按照權(quán)重先排序
  11. else?$ordersql?=?"?ORDER?BY?arc.sortrank?$orderWay";
OK 現(xiàn)在把這個(gè)文檔保存了 我們就可以在首頁使用 orderby='weight' 進(jìn)行排序了。

贊 (

發(fā)表評(píng)論