织梦CMS让列表页按文章的更新日期pubdate排序

dedecms文章默认排序有id,权重,热点但就是没有更新时间来了,那么我们如果想要做pubdate排序就必须要进行一些简单的修改了,下面一起来看看吧.
 
注意:在列表页模板,即使你指定orderby='pubdate',但实际还是不是按照pubdate排序的,通过下文可知它是按sortrank排序的.
 
解决办法:include/arc.listview.class.php 600行左右如下:
 
//排序方式   
$ordersql = '';   
if($orderby=="senddate" || $orderby=="id") {   
    $ordersql=" order by arc.id $orderWay";   
}   
else if($orderby=="hot" || $orderby=="click") {   
    $ordersql = " order by arc.click $orderWay";   
}   
else if($orderby=="lastpost") {   
    $ordersql = "  order by arc.lastpost $orderWay";   
}   
else {   
    $ordersql=" order by arc.sortrank $orderWay";   
}  
可以看到当$orderby为"pubdate"时,排序依据变为$ordersql=" order by arc.sortrank $orderWay";
 
需要修改两个地方:
 
修改1)接受pubdate排序方式,代码如下:
 
//排序方式  
 
$ordersql = '';   
if($orderby=="senddate" || $orderby=="id") {   
    $ordersql=" order by arc.id $orderWay";   
}   
else if($orderby=="hot" || $orderby=="click") {   
    $ordersql = " order by arc.click $orderWay";   
}   
else if($orderby=="lastpost") {   
    $ordersql = "  order by arc.lastpost $orderWay";   
}   
// add by redice   
// fix "order by pubdate" bug   
else if($orderby=="pubdate")   
{  //开源软件:Cuoxin.com
    $ordersql = "  order by arc.pubdate $orderWay";   
}   
// end add   
else {   
    $ordersql=" order by arc.sortrank $orderWay";   
}
修改2)直接查询archives表,查询arctiny虽然快,但是可惜arctiny表没有pubdate字段,修改include/arc.listview.class.php 650行左右,代码如下:
 
if(ereg('hot|click|lastpost|pubdate',$orderby))   
{   
...   
}   
//修改为
if(ereg('hot|click|lastpost',$orderby)) //   
{   
...   
}
 

dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。