Discuz!小编 发表于 2024-8-12 21:27:47

首页四格最新主题如何实现最新主题+最新回复共同排序 New

论坛文章都需要审核(休息,忘记审核时)每次访问论坛时总是看到相同的帖子,用久厌倦了
我知道答案 回答被采纳将会获得1 贡献 已有9人回答

杰克 发表于 2024-8-12 21:27:53

最新主题,生成前五个,最新回复,生成后五个。它们统一用最新时间排序

海军大都督 发表于 2024-8-12 21:28:51

你自己想好算法,找人开发几百块。

让别人连算法都要给你想,那估计就上千了

海军大都督 发表于 2024-8-12 21:29:39

算法版块回复时间排序就行了,新帖和回帖序保证新鲜内容+提升优质内容两全其美
算法在source/module/forum/forum_index.php   管理可以指点一下如何修改吗
$grids = array();if($_G['setting']['grid']['showgrid']) {      loadcache('grids');      $cachelife = $_G['setting']['grid']['cachelife'] ? $_G['setting']['grid']['cachelife'] : 600;      $now = dgmdate(TIMESTAMP, lang('forum/misc', 'y_m_d')).' '.lang('forum/misc', 'week_'.dgmdate(TIMESTAMP, 'w'));      if(TIMESTAMP - $_G['cache']['grids']['cachetime'] < $cachelife) {                $grids = $_G['cache']['grids'];      } else {                $images = array();                $_G['setting']['grid']['fids'] = in_array(0, $_G['setting']['grid']['fids']) ? 0 : $_G['setting']['grid']['fids'];                if($_G['setting']['grid']['gridtype']) {                        $grids['digest'] = C::t('forum_thread')->fetch_all_for_guide('digest', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);                } else {                        $images = C::t('forum_threadimage')->fetch_all_order_by_tid_for_guide(10, 0, $_G['setting']['grid']['fids']);                        foreach($images as $key => $value) {                              $tids[$value['tid']] = $value['tid'];                        }                        $grids['image'] = C::t('forum_thread')->fetch_all_by_tid($tids);                }                $grids['newthread'] = C::t('forum_thread')->fetch_all_for_guide('newthread', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);                $grids['newreply'] = C::t('forum_thread')->fetch_all_for_guide('reply', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);                $grids['hot'] = C::t('forum_thread')->fetch_all_for_guide('hot', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);                $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');                foreach($grids as $type => $gridthreads) {                        foreach($gridthreads as $key => $gridthread) {                              $gridthread['dateline'] = str_replace('"', '\'', dgmdate($gridthread['dateline'], 'u', '9999', getglobal('setting/dateformat')));                              $gridthread['lastpost'] = str_replace('"', '\'', dgmdate($gridthread['lastpost'], 'u', '9999', getglobal('setting/dateformat')));                              if($gridthread['highlight'] && $_G['setting']['grid']['highlight']) {                                        $string = sprintf('%02d', $gridthread['highlight']);                                        $stylestr = sprintf('%03b', $string);                                        $gridthread['highlight'] = ' style="';                                        $gridthread['highlight'] .= $stylestr ? 'font-weight: bold;' : '';                                        $gridthread['highlight'] .= $stylestr ? 'font-style: italic;' : '';                                        $gridthread['highlight'] .= $stylestr ? 'text-decoration: underline;' : '';                                        $gridthread['highlight'] .= $string ? 'color: '.$_G['forum_colorarray'][$string] : '';                                        $gridthread['highlight'] .= '"';                              } else {                                        $gridthread['highlight'] = '';                              }                              if($_G['setting']['grid']['textleng']) {                                        $gridthread['oldsubject'] = dhtmlspecialchars($gridthread['subject']);                                        $gridthread['subject'] = cutstr($gridthread['subject'], $_G['setting']['grid']['textleng']);                              }                              $grids[$type][$key] = $gridthread;                        }                }                if(!$_G['setting']['grid']['gridtype']) {                        $grids['slide'] = $focuspic = $focusurl = $focustext = array();                        $grids['focus'] = 'config=5|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';                        foreach($grids['image'] as $ithread) {                              if($ithread['displayorder'] < 0) {                                        continue;                              }                              if($images[$ithread['tid']]['remote']) {                                        $imageurl = $_G['setting']['ftp']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];                              } else {                                        $imageurl = $_G['setting']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];                              }                              $grids['slide'][$ithread['tid']] = array(                                                'image' => $imageurl,                                                'url' => 'forum.php?mod=viewthread&tid='.$ithread['tid'],                                                'subject' => addslashes($ithread['subject'])                                        );                        }                        $grids['slide'] = array_reverse($grids['slide'], true);                }                $grids['cachetime'] = TIMESTAMP;                savecache('grids', $grids);      }模板插入点

template/default/touch/forum/discuz.htm

</div>                <div id="tabs-box" class="swiper-container listbox cl">                        <div class="swiper-wrapper">                              <div class="swiper-slide">                                        <ul>                                        <!--{loop $grids['newthread'] $thread}-->                                        <!--{if !$thread['forumstick'] && $thread['closed'] > 1 && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}-->                                                <!--{eval $thread['tid']=$thread['closed'];}-->                                        <!--{/if}-->                                        <!--{eval $i++;}-->                                        <!--{eval $typeid = $tids_typeids[$thread['tid']];}-->                                        <li><a href="forum.php?mod=viewthread&tid=$thread['tid']"{if $thread['highlight']} $thread['highlight']{/if}><span class="mybk">[{$typeid_name[$typeid]}]</span><span class="mnum">$i</span>{$thread['oldsubject']}</a></li>                                        <!--{/loop}-->                                        </ul>                              </div>

Sylvia 发表于 2024-8-12 21:30:25

现有的算法不是不满足你嘛,你不是要混合排序嘛,那原来的算法就没任何作用了,混合不是说两个东西凑到一起就完事了的,混合是全新的一套算法了

KarlMock59 发表于 2024-8-12 21:30:55

啊啊啊啊啊啊啊啊

Sylvia 发表于 2024-8-12 21:31:03

修改方法
第一步


template/default/touch/forum/discuz.htm
搜索<!--{loop $grids['newthread'] $thread}-->

修改为<!--{loop $grids['lastpost'] $thread}-->
第二步
source/module/forum/forum_index.php

搜索$grids['newthread'] = C::t('forum_thread')->fetch_all_for_guide('newthread', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);

修改为

$grids['lastpost'] = C::t('forum_thread')->fetch_all_for_guide('lastpost', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);

杰克 发表于 2024-8-12 21:31:17

查了一下fetch_all_for_guide 这个方法,

按你这个写法 仅仅是 按 "最后回复时间 " 倒序排列;

修改前 是按 主题发布时间 倒序排列;

瑾瑜 发表于 2024-8-12 21:32:13

对啊看不懂代码 对于你来仅是仅仅

杰克 发表于 2024-8-12 21:33:00

我说仅仅的意思是:

你这代码 实现的效果 和 你前边写的 要求不符
页: [1]
查看完整版本: 首页四格最新主题如何实现最新主题+最新回复共同排序 New