首页 > CMS > 织梦DEDE > 正文

dede5.6和5.7版本中实现dede:list按权重排序

2024-07-12 08:26:21
字体:
来源:转载
供稿:网友
文章介绍

一、dedecms v5.6列表页标签{dede:list}增加按权重排序标签

dedecms v5.6版本已经中已经添加权重字段,并且在{dede:arclist}标签中默认可以使用。但在列表页的标签 {dede:list}中是还是无法按权重实现排序。其实解决方法很简单,下面给出方法:

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)) ,保存文件。

这个时候在列表页里就可以使用{dede:list pagesize='5' orderby='weight'} 进行排序了。

二、DEDE 5.7 首页【arclist】增加按权重排序

1、在织梦系统中找到以下目录/include/taglib中的arclist.lib.php文件并打开

大约在74 、75行找到:

// arclist是否需要weight排序,默认为"N",如果需要排序则设置为"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";//如果没有特定设置排序则按照权重先排序

else $ordersql = " ORDER BY arc.sortrank $orderWay";

OK 现在把这个文档保存了 我们就可以在首页使用 orderby='weight' 进行排序了。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表