前段時間應壇友的需求做了個這個功能,現在放出來希望大家會喜歡。問題是:
有個文章列表要顯示文章 如果文章時間發布的越近的越靠前 時間一樣看評論 如果評論越近的越靠前,有點像論壇的帖子列表
修改方法:
找到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';