bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Forum system study Discuz 在首頁顯示最新發表與最新回覆列表 ...
查看: 16761|回復: 1
go

Discuz 在首頁顯示最新發表與最新回覆列表 [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2007-6-12 17:20 |只看該作者 |倒序瀏覽 |打印
適用版本: 5.5.0


1.) 修改 include/cache.func.php

尋找

  1. 'medals' => array('medals'),
複製代碼


在之後加入

  1. 'newtopic' => array('newtopic'),
  2. 'newreply' => array('newreply'),
複製代碼


尋找

  1. case 'medals':
  2. $table = 'medals';
  3. $cols = 'medalid, name, image';
  4. $conditions = "WHERE available='1'";
  5. break;
複製代碼


在之後加入(選擇兩者之一)

  1. //所有討論區都可以在最新(發文/回覆)列出
  2. case 'newtopic' :
  3. $table = 'threads t';
  4. $cols = 't.tid, t.typeid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name, tt.name AS idname';
  5. $conditions = "LEFT JOIN {$tablepre}threadtypes tt ON (tt.typeid=t.typeid) LEFT JOIN {$tablepre}forums f ON (f.fid=t.fid) WHERE t.fid<>'$fid' ORDER BY t.dateline DESC LIMIT 0, 6";
  6. break;
  7. case 'newreply' :
  8. $table = 'threads t';
  9. $cols = 't.tid, t.typeid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name, tt.name AS idname';
  10. $conditions = "LEFT JOIN {$tablepre}threadtypes tt ON (tt.typeid=t.typeid) LEFT JOIN {$tablepre}forums f ON (f.fid=t.fid) WHERE t.fid<>'$fid' AND t.replies !=0 ORDER BY t.lastpost DESC LIMIT 0, 6";
  11. break;
複製代碼
  1. //特定討論區的主題不在最新(發文/回覆)列出
  2. case 'newtopic' :
  3. $table = 'threads t';
  4. $cols = 't.tid, t.typeid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name, tt.name AS idname';
  5. $fids = '';//不需顯示的討論區ID,逗號分隔
  6. $conditions = "LEFT JOIN {$tablepre}threadtypes tt ON (tt.typeid=t.typeid) LEFT JOIN {$tablepre}forums f ON (f.fid=t.fid) WHERE t.fid<>'$fid' AND f.fid NOT IN ($fids) ORDER BY t.dateline DESC LIMIT 0, 6";
  7. break;
  8. case 'newreply' :
  9. $table = 'threads t';
  10. $cols = 't.tid, t.typeid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name, tt.name AS idname';
  11. $fids = '';//不需顯示的討論區ID,逗號分隔
  12. $conditions = "LEFT JOIN {$tablepre}threadtypes tt ON (tt.typeid=t.typeid) LEFT JOIN {$tablepre}forums f ON (f.fid=t.fid) WHERE t.fid<>'$fid' AND f.fid NOT IN ($fids) AND  t.replies !=0 ORDER BY t.lastpost DESC LIMIT 0, 6";
  13. break;
複製代碼


尋找

  1. case 'forumlinks':
  2. global $forumlinkstatus;
複製代碼


在之前加入

  1. case 'newtopic':
  2. $hack_cut_str = 36;
  3. $new_post_threadlist = array();
  4. $nthread = array();
  5. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  6. while($nthread = $db->fetch_array($query)) {
  7. $nthread['forumname'] = $nthread['name'];
  8. $nthread['view_subject'] = $nthread[idname] ? cutstr( "$nthread[idname] $nthread[subject]",$hack_cut_str) : cutstr($nthread['subject'],$hack_cut_str);
  9. $nthread['subject'] = $nthread['subject'];
  10. $nthread['date']= gmdate('Y-n-j G:i', $nthread['dateline'] + 8 * 3600);
  11. $nthread['lastreplytime']= gmdate('Y-n-j G:i', $nthread[lastpost] + 8 * 3600);
  12. if($nthread['highlight']) {
  13. $string = sprintf('%02d', $nthread['highlight']);
  14. $stylestr = sprintf('%03b', $string[0]);
  15. $nthread['highlight'] = 'style="';
  16. $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  17. $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  18. $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  19. $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  20. $nthread['highlight'] .= '"';
  21. } else {
  22. $nthread['highlight'] = '';
  23. }
  24. $new_post_threadlist = $nthread[replies] ? "<a href=\"redirect.php?tid=$nthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $nthread[forumname]\r\n標題: $nthread[subject]\r\n作者: $nthread[author]\r\n發表時間: $nthread[date]\r\n瀏覽次數: $nthread[views] 次 \r\n回覆: $nthread[replies] 次\r\n最後回覆: $nthread[lastreplytime]\r\n最後發表: $nthread[lastposter]\" $nthread[highlight] >$nthread[view_subject]</a><br>" : "<a href=\"redirect.php?tid=$nthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $nthread[forumname]\r\n標題: $nthread[subject]\r\n作者: $nthread[author]\r\n發表時間: $nthread[date]\r\n瀏覽次數: $nthread[views] 次\r\n回覆: 暫時沒有回覆\" $nthread[highlight] >$nthread[view_subject]</a><br>";
  25. $data[] = array('content' => $new_post_threadlist);
  26. }
  27. break;
  28. case 'newreply':
  29. $hack_cut_str = 36;
  30. $new_reply_threadlist = array();
  31. $rthread = array();
  32. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  33. while($rthread = $db->fetch_array($query)) {
  34. $rthread['forumname'] = $rthread['name'];
  35. $rthread['view_subject'] = $rthread[idname] ? cutstr( "$rthread[idname] $rthread[subject]",$hack_cut_str) : cutstr($rthread['subject'],$hack_cut_str);
  36. $rthread['subject'] = $rthread['subject'];
  37. $rthread['date']= gmdate('Y-n-j G:i', $rthread['dateline'] + 8 * 3600);
  38. $rthread['lastreplytime']= gmdate('Y-n-j G:i', $rthread['lastpost'] + 8 * 3600);
  39. if($rthread['highlight']) {
  40. $string = sprintf('%02d', $rthread['highlight']);
  41. $stylestr = sprintf('%03b', $string[0]);
  42. $rthread['highlight'] = 'style="';
  43. $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  44. $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  45. $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  46. $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  47. $rthread['highlight'] .= '"';
  48. } else {
  49. $rthread['highlight'] = '';
  50. }
  51. $new_reply_threadlist = "<a href=\"redirect.php?tid=$rthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $rthread[forumname]\r\n標題: $rthread[subject]\r\n作者: $rthread[author]\r\n發表時間: $rthread[date]\r\n瀏覽次數: $rthread[views] 次\r\n回覆: $rthread[replies] 次\r\n最後回覆: $rthread[lastreplytime]\r\n最後發表: $rthread[lastposter]\" $rthread[highlight]>$rthread[view_subject]</a><br>";
  52. $data[] = array('content' => $new_reply_threadlist);
  53. }
  54. break;
複製代碼



2.) 修改 include/newthread.inc.php

尋找

  1. showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra");
複製代碼


在之前加入

  1. require DISCUZ_ROOT.'./include/cache.func.php';
  2. updatecache('newtopic');
複製代碼



3.) 修改 include/newreply.inc.php

尋找

  1. showmessage('post_reply_succeed', "viewthread.php?tid=$tid&pid=$pid&page=".(@ceil(($thread['replies'] + 2) / $ppp))."&extra=$extra#pid$pid");
複製代碼


在之前加入

  1. require DISCUZ_ROOT.'./include/cache.func.php';
  2. updatecache('newreply');
  3. updatecache('newtopic');
複製代碼



4.) 修改 topicadmin.php

尋找

  1. require_once DISCUZ_ROOT.'./include/misc.func.php';
複製代碼


在之後加入

  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
複製代碼


尋找

  1. showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
複製代碼


在之前加入

  1. updatecache('newtopic');
  2. updatecache('newreply');
複製代碼



5.) 修改 index.php

找到

  1. $catlist = $forumlist = $sublist = $pmlist = array();
複製代碼


在之前加入

  1. require_once DISCUZ_ROOT.'./include/misc.func.php';
  2. include './forumdata/cache/cache_newtopic.php';
  3. include './forumdata/cache/cache_newreply.php';
複製代碼


尋找

  1. foreach(array('forumlinks', 'birthdays', 'supe_updateusers') as $key) {
複製代碼


修改成

  1. foreach(array('forumlinks', 'birthdays', 'supe_updateusers', 'foruminfo') as $key) {
複製代碼



6.) 建立範本檔 templates/default/foruminfo.htm

內容輸入

  1. <div class='spaceborder spacebottom' style="width: {TABLEWIDTH}; clear: both; margin-top: 5px;">
  2. <table cellspacing="0" cellpadding="4" width='100%'>
  3. <tr class='header'><td>New Topic</td><td>New Reply</td></tr>
  4. <tr>
  5. <td class='smalltxt'>
  6. <!--{loop $_DCACHE['newtopic'] $newtopic}-->
  7. $newtopic[content]
  8. <!--{/loop}-->
  9. </td>
  10. <td class='smalltxt'>
  11. <!--{loop $_DCACHE['newreply'] $newreply}-->
  12. $newreply[content]
  13. <!--{/loop}-->
  14. </td>
  15. </tr>
  16. </table>
  17. </div>
複製代碼



7.) 修改範本檔 templates/default/discuz.htm

找到

  1. <!--{if !empty($announcements)}-->
  2. <div id="announcement">$announcements</div><script type="text/javascript">announcement();</script>
  3. <!--{/if}-->
複製代碼


在之後加入

  1. {template foruminfo}
複製代碼



8.) 然後進後台執行 [系統工具 > 更新緩存]
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

2#
發表於 2008-1-21 18:58 |只看該作者
在 Disciz 6.0.0 版只有一個部分不同

3.) 修改 include/newreply.inc.php

尋找
  1. showmessage($replymessage, "viewthread.php?tid=$tid&pid=$pid&page=".(@ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $ppp))."&extra=$extra#pid$pid");
複製代碼
在之前加入
  1. require DISCUZ_ROOT.'./include/cache.func.php';
  2. updatecache('newreply');
  3. updatecache('newtopic');
複製代碼
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2024-4-26 00:29 , Processed in 0.011705 second(s), 10 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.