作者
n2n1
发布于2021-4-13 18:27:43
来自河北
discuz文章设置标签后,相关的帖子现在是按照时间先后来排序的,显示时间是最早发布的,结果最新的相关帖子无法展现出来,那标签的聚合作用还有啥作用啊,聚合的都是相同的老帖子.
现在只需要修改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;
- }
复制代码
|
|