让织梦likearticle标签支持orderby的办法

2021-03-08 织梦安装使用
  • 文章介绍
我们都知道织梦的{dede:likearticle}没有orderby这个功能,我们需要让它支持orderby要怎么操作呢?
 
下面是修改方法
 
 打开/include/taglib/likearticle.lib.php文件
 
找到
 
if( empty($arcid) || $byabs==0 ) {
   $orderquery = " order by arc.id desc ";
}
else {
   $orderquery = " order by ABS(arc.id - ".$arcid.") ";
}
 
改成:
 
if($orderby=='hot' || $orderby=='click') $orderquery = " order by arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $orderquery = " orderby arc.sortrank $orderWay";
else if($orderby == 'id') $orderquery = " order by arc.id $orderWay";
else if($orderby == 'near') $orderquery = " order by ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $orderquery = " order by arc.lastpost $orderWay";
else if($orderby == 'scores') $orderquery = " order by arc.scores $orderWay";
else if($orderby == 'rand') $orderquery = " order by rand()";
else if($orderby == 'weight') $orderquery = " order by arc.weight asc";//如果没有特定设置排序则按照权重先排序
else $orderquery = " order by arc.sortrank $orderWay";
 

上一篇:织梦列表页调取文章body的内容的办法

下一篇:织梦dedecms列表循环判断增加样式的办法

专业的织梦模板定制下载站,在线购买后即可下载!

商业源码

跟版网模板,累计帮助5000+客户企业成功建站,为草根创业提供助力!

立刻开启你的建站之旅
QQ在线客服

服务热线

织梦建站咨询