现在只需要修改2个文件就可以实现最新发表的排在前面,在文章内容页和forumthread.php,修改以下代码.
fetch_all_by_tid 改成 fetch_all_by_relatedateline
大概在189行添加下面代码:
public function fetch_all_by_relatedateline($tids, $start = 0, $limit = 0, $tableid = 0) {$data = array();170
if(($data = $this->fetch_cache($tids)) === false || count($tids) != count($data)) {
if(is_array($data) && !empty($data)) {
$tids = array_diff($tids, array_keys($data));
}
if($data === false) $data = array();
if(!empty($tids)) {
$parameter = array($this->get_table_name($tableid), $tids);
$query = DB::query("SELECT * FROM %t WHERE tid IN(%n) order by dateline desc ".DB::limit($start, $limit), $parameter);
while($value = DB::fetch($query)) {
$data[$value['tid']] = $value;
$this->store_cache($value['tid'], $value, $this->_cache_ttl);
}
}
}
return $data;
}
教程到此结束.