最新关于织梦DEDECMS文章排序方式及调用方法
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>效果如下图所示:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<img style="max-width:100%!important;height:auto!important;"title="最新关于织梦DEDECMS文章排序方式及调用方法" alt="最新关于织梦DEDECMS文章排序方式及调用方法" src="https://zhuji.jb51.net/uploads/img/202305/9ed30f9b38434e52787231c9272d7b71.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
标签dede:arclist的排序是通过orderby来指定的,如下:</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:plain;">
{dede:arclist orderby='排序字段' }
{/dede:arclist}
orderby='sortrank' 文档排序方式
§ orderby='hot' 或 orderby='click' 表示按点击数排列
§ orderby='sortrank' 或 orderby='pubdate' 按出版时间排列
§ orderby='near'
§ orderby=='lastpost' 按最后评论时间
§ orderby=='scores' 按得分排序
§ orderby='id' 按文章ID排序
§ orderby='rand' 随机获得指定条件的文档列表
§ orderby='weight' 按照权重进行排序 5.6版本新添加功能
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
而能给orderby赋值的只能是上面列出的值,也就是说dede:arclist 标签只能按照上面列出的字段排序。</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:arclist row='14' titlelen='48' orderby='weight' typeid='9' idlist=''}
<li><span class="title f_l"><a href="" title=""> if (@me['shorttitle']=='') @me=@me['title'];else @me=@me['shorttitle'];</a></span><span class="pubdate f_r"></span></li>
{/dede:arclist}</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
只不过现在权重是按照从小到大升序排列的,而默认的文章权重和文章ID相同,所以,你要是想让文章排到最前面,只有将权重改为负数。 <br>
但是,这跟我们平时心理上的习惯不太一样,所以解决的办法就是</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
1、首先将文档默认权重值设为0,将\dede\templets\article_add.htm中的</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<td width="122"><input name="weight" type="text" id="weight" value="<?php echo $maxWright['cc'];?>" />(越小越靠前)</td></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
改为 <td width="122"><input name="weight" type="text" id="weight" value="0" />(越大越靠前)</td> ;</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
2.、为 else if($orderby == 'weight') $ordersql = " order by arc.weight $orderWay , arc.sortrank $orderWay";//如果没有特定设置排序则按照权重先排序,如果权重相等,则按照发布时间降序排列<br>
这样就可以按照权重从大到小进行排列了~~</p>
頁:
[1]