前段时间应坛友的需求做了个这个功能,现在放出来希望大家会喜欢。问题是:
有个文章列表要显示文章 如果文章时间发布的越近的越靠前 时间一样看评论 如果评论越近的越靠前,有点像论坛的帖子列表
修改方法:
找到inc/artic_function.php 的这个函数:ListThisSort($rows,$leng=50)
将其中的代码:
$SQL="A LEFT JOIN {$pre}reply$erp R ON A.aid=R.aid WHERE R.topic=1 $_fid_sql $SQL_yz ORDER BY $ORDER $DESC LIMIT $min,$rows";
$which='A.*,R.content';
修改为:
$SQL="A LEFT JOIN {$pre}reply$erp R ON A.aid=R.aid
LEFT JOIN (
SELECT aid, content, MAX( posttime )AS posttime
FROM`{$pre}comment`
GROUP BY aid
ORDER BY posttime DESC
) AS C
ON C.aid = A.aid
WHERE R.topic=1 $_fid_sql AND A.yz =1
ORDER BY CASE WHEN A.posttime > C_posttime
THEN A.posttime
ELSE C_posttime
END
DESC
LIMIT $min,$rows";
$which='A.aid, A.title, A.fid, A.fname, A.comments, A.posttime,
if( isnull( C.posttime ) , 0, C.posttime )AS C_posttime, C.content AS C_content';