discuz相关帖子功能修改随机显示不依赖标签

discuz相关帖子功能修改随机显示不依赖标签

只需要修改
source\module\forum\forum_viewthread.php

找到:
 if($post['tags']) {
 $post['relateitem'] = getrelateitem($post['tags'], $post['tid'], $_G['setting']['relatenum'], $_G['setting']['relatetime']);
 }
在后面添加:
 $post['relateitem'] = getrelateitemx($post['fid'], $_G['setting']['relatenum']);

在function  getrelateitem 函数后添加
function getrelateitemx($fid, $relatenum)
{
    $limit = $relatenum;
    if (!$limit) {
        return '';
    }

    $hotlist=DB::fetch_all("SELECT tid,subject,fid FROM ".DB::table('forum_thread')." where fid=$fid and displayorder>=0 order by rand() LIMIT 0,$limit");
        
    return $hotlist;
}

在后台界面设置相关帖子数量即可
huan

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: