一、織夢(mèng)dedecms v5.6列表頁(yè)標(biāo)簽{dede:list}增加按權(quán)重排序標(biāo)簽 dedecms v5.6版本已經(jīng)中已經(jīng)添加權(quán)重字段,并且在{dede:arclist}標(biāo)簽中默認(rèn)可以使用。但在列表頁(yè)的標(biāo)簽 {dede:list}中是還是無(wú)法按權(quán)重實(shí)現(xiàn)排序。其實(shí)解決方法很簡(jiǎn)單,下面給出方法: 1、打開\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"; } else { $ordersql=" order by arc.sortrank $orderWay"; } 這段代碼中間添加以上紅色代碼。 4、向下找到if(ereg('hot|click|lastpost',$orderby))或者是if(preg_match('/hot|click|lastpost/', $orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby))或者是if(preg_match('/hot|click|lastpost|weight/', $orderby)) ,保存文件。 這個(gè)時(shí)候在列表頁(yè)里就可以使用{dede:list pagesize='5' orderby='weight'} 進(jìn)行排序了。 二、DEDE 5.7 首頁(yè)【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行找到 //文檔排序的方式 $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 $ordersql = " ORDER BY arc.sortrank $orderWay"; 修改為: //文檔排序的方式 $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";//如果沒有特定設(shè)置排序則按照權(quán)重先排序 else $ordersql = " ORDER BY arc.sortrank $orderWay"; OK 現(xiàn)在把這個(gè)文檔保存了 我們就可以在首頁(yè)使用 orderby='weight' 進(jìn)行排序了。 |
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 織夢(mèng)5.6和5.7版本中實(shí)現(xiàn)dede:list按權(quán)重排序