DedeCMS用于图片站WEB开发时,需要随机调用文章、图集和关联文章、图集功能,以增加用户黏度,属于站内优化重要一部分。一般用标签调用都有排序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";
注意到排序是针对数字而言,因此只要这里就可以拓展成许多自定义排序,比如DedeCMS做商城时按照价格排序功能就可以这样做。
在上面代码最后一行前增加一行代码
else if($orderby == 'trueprice') $ordersql = " order by addf.trueprice $orderWay";
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!