汕头麻辣烫 發表於 2024-12-9 00:00:00

详解dede:list和dede:arclist列表按权重排序修改方法

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