文章介绍
一、dedecms v5.6列表页标签{dede:list}增加按权重排序标签
dedecms v5.6版本已经中已经添加权重字段,并且在{dede:arclist}标签中默认可以使用。但在列表页的标签 {dede:list}中是还是无法@ V l 1 !按权重实现排序。其实解决方法很简单,下面- 2 c A n A T P Q给出方法:
1、打开\include\目录中的arc.listview.class.php文件,搜索“排序方式”,然后在5 @ w S T d m j +
else if($orderby=="lastpost") {2 r n 6 ~
$ordersql = " order by arc.lastpost $orderWay"I O ^ } z N G;
}
else if($orderby == "weight") {
$ordersql = " order by arc.wX V B C O 0 W !eight asc";
}
else {
$ordersql=" order by arc.sortrank $orderWay";
}
这段代码中间添加以上1 u B 5 ( L红色代码。
4、向下找到if(ereg('hot|click|lastpost',$orderby))或者是if(preg_maC p ;tch('/hot|click|lastpost/', $orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby))或者是if(D i D V Zpreg_match('/hot|click|lastpost|wei{ 7 & M Vght/', $o: & ! = l ,rderby)) ,保2 ( b H } M ) A ]存文件。
这个时候在列表页里! 7 Y p L就可以使用{dede:list pagesize='5' orderby='weight'} 进行排序了。
二、DEDE 5.7 首页【arclist】增加按权重排序
1、在织梦系统中找到以下目录\include\taglib中的arclist.lib.php文件并打开
大约在74 、75行找到:
// arclist是否需要2 K f Y M H ` vweight排序,默认为"N",如果需要排序则设置为"Y"
$isweight = $ctag->n ( _ # X X O 3GetAtt('isweight');
把这行修改为:
$weight = $ctag-&gW \ B .t;GetAtt('weight');
大约在327行找到
//文档排序的方式
$ordersql = '';
if($orderby=='hot' |d 3 { G| $orderby=='click') $or r 5 f Wrdersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortran- w 2 $ Hk' || $orderby=='pubdate') $, d y 9 |ordersql = " ORDER BY ar+ ^ n F 9 E _c.; ! csortrank $orderWay";[ _ \ P 4 b f K Y
else if($orderby == 'id') $ordersql = " ORDER Bs % H } L TY arc.id $orderWay";
else if($orderbP c 6 \ f $y ==G 8 T a s $ E 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.8 q m X e m M")";
else if($or, . ?derby == 'last: p V : ^ + T # |post') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = "` Z u = 8 ORDER BY arc.scores $orderWe _ V ^ fay";
else ifF v p r [ )($orderby == 'rand') $ordersql = " ORDER BY rand()";
else $ordersql = " ORp M QDER BY arc.sortri c g 3ank $orderWay";
修改为:
//文档排序的方式
$ordersql = '';
if($orderby=='hot' || $orderby=='0 R T Bclick') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc9 Q 5 G * ) V n D.sortrank $orderWay";
else if($orderby == 'id') $o_ - 6 b W ( : ,rdersql = " ORDER BY arc7 I g.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arc} U qid.")";
else if($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderbyL j T } * t 0 Y ] == 'scores') $ordersql = "a O k l m Y ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else if($order@ N l e ~ Pby == 'weight') $ordersql = " order by arc.weight asc";//如果没有特定设置排序则按照权重先排序
else $ordersql = "X ! g \ V S ^ : $ O( J % 5 *RDER BY arc.sortrank $orderWay";
OK 现在把这个文档保存了 我们就可以在首页使用 orderby='weight' 进行排序了。