详解dede:list和dede:arclist列表按权重排序修改方法
<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">有时候客户需要某几篇文章按照自己的意思排列顺序,就要用到按权重排序,下面介绍织梦dedecms的dede:list和dede:arclist列表按权重排序修改方法。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
倒序 orderway='asc'</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
orderway是设置排序的方式,值为desc和asc</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
dedecms列表页实现文档按权重weight排序</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
1,在list_artcile.htm模板中使用</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:xhtml;">{dede:list pagesize='12′ orderby='weight' orderway='desc'}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
2,然后修改include目录下的arc.listview.class.php</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
查找else if($orderby=="lastpost") { $ordersql = " ORDER BY arc.lastpost $orderWay";} , dedecms5.7sp2大概在768行</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
在下面补充</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">else if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; }</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
3,同样是这个文件,</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
查找“if(preg_match('/hot|click|lastpost/', $orderby))”</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
改为:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">if(preg_match('/hot|click|weight|lastpost/', $orderby))</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
上面三个步骤,即可实现列表页内容按权重排序,越小越靠前。仅限dedecms v5.7 SP2测试!</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
dede:arclist按权重排序的修改方法</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
1、在织梦系统中找到以下目录\include\taglib中的arclist.lib.php文件并打开</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
大约在74 、75行找到:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">// arclist是否需要weight排序,默认为"N",如果需要排序则设置为"Y"
$isweight = $ctag->GetAtt('isweight');</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
把这行修改为:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">$weight = $ctag->GetAtt('weight');</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
或者修改了 170行 $isweight='N' 的值为Y</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
大约在327行找到,并修改</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">//文档排序的方式
$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";</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
下添加</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">else if($orderby == 'weight') $ordersql = " order by arc.weight $orderWay";
//主要是这一句,应该是这一句就够了,需要修改的小伙伴,试一下只改这里,上面绿色文字不改看看是不是也可以的</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
调用方法:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">orderby='weight' orderway='desc' //desc和asc</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁:
[1]