bestlong 怕失憶論壇's Archiver

bestlong 發表於 2007-6-12 17:20

Discuz 在首頁顯示最新發表與最新回覆列表

適用版本: 5.5.0


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

尋找

[code]
'medals' => array('medals'),
[/code]

在之後加入

[code]
'newtopic' => array('newtopic'),
'newreply' => array('newreply'),
[/code]

尋找

[code]
case 'medals':
$table = 'medals';
$cols = 'medalid, name, image';
$conditions = "WHERE available='1'";
break;
[/code]

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

[code]
//所有討論區都可以在最新(發文/回覆)列出
case 'newtopic' :
$table = 'threads t';
$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';
$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";
break;
case 'newreply' :
$table = 'threads t';
$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';
$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";
break;
[/code]
[code]
//特定討論區的主題不在最新(發文/回覆)列出
case 'newtopic' :
$table = 'threads t';
$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';
$fids = '';//不需顯示的討論區ID,逗號分隔
$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";
break;
case 'newreply' :
$table = 'threads t';
$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';
$fids = '';//不需顯示的討論區ID,逗號分隔
$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";
break;
[/code]

尋找

[code]
case 'forumlinks':
global $forumlinkstatus;
[/code]

在之前加入

[code]
case 'newtopic':
$hack_cut_str = 36;
$new_post_threadlist = array();
$nthread = array();
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
while($nthread = $db->fetch_array($query)) {
$nthread['forumname'] = $nthread['name'];
$nthread['view_subject'] = $nthread[idname] ? cutstr( "$nthread[idname] $nthread[subject]",$hack_cut_str) : cutstr($nthread['subject'],$hack_cut_str);
$nthread['subject'] = $nthread['subject'];
$nthread['date']= gmdate('Y-n-j G:i', $nthread['dateline'] + 8 * 3600);
$nthread['lastreplytime']= gmdate('Y-n-j G:i', $nthread[lastpost] + 8 * 3600);
if($nthread['highlight']) {
$string = sprintf('%02d', $nthread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$nthread['highlight'] = 'style="';
$nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
$nthread['highlight'] .= '"';
} else {
$nthread['highlight'] = '';
}
$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>";
$data[] = array('content' => $new_post_threadlist);
}
break;
case 'newreply':
$hack_cut_str = 36;
$new_reply_threadlist = array();
$rthread = array();
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
while($rthread = $db->fetch_array($query)) {
$rthread['forumname'] = $rthread['name'];
$rthread['view_subject'] = $rthread[idname] ? cutstr( "$rthread[idname] $rthread[subject]",$hack_cut_str) : cutstr($rthread['subject'],$hack_cut_str);
$rthread['subject'] = $rthread['subject'];
$rthread['date']= gmdate('Y-n-j G:i', $rthread['dateline'] + 8 * 3600);
$rthread['lastreplytime']= gmdate('Y-n-j G:i', $rthread['lastpost'] + 8 * 3600);
if($rthread['highlight']) {
$string = sprintf('%02d', $rthread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$rthread['highlight'] = 'style="';
$rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
$rthread['highlight'] .= '"';
} else {
$rthread['highlight'] = '';
}
$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>";
$data[] = array('content' => $new_reply_threadlist);
}
break;
[/code]


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

尋找

[code]
showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra");
[/code]

在之前加入

[code]
require DISCUZ_ROOT.'./include/cache.func.php';
updatecache('newtopic');
[/code]


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

尋找

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

在之前加入

[code]
require DISCUZ_ROOT.'./include/cache.func.php';
updatecache('newreply');
updatecache('newtopic');
[/code]


4.) 修改 topicadmin.php

尋找

[code]
require_once DISCUZ_ROOT.'./include/misc.func.php';
[/code]

在之後加入

[code]
require_once DISCUZ_ROOT.'./include/cache.func.php';
[/code]

尋找

[code]
showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
[/code]

在之前加入

[code]
updatecache('newtopic');
updatecache('newreply');
[/code]


5.) 修改 index.php

找到

[code]
$catlist = $forumlist = $sublist = $pmlist = array();
[/code]

在之前加入

[code]
require_once DISCUZ_ROOT.'./include/misc.func.php';
include './forumdata/cache/cache_newtopic.php';
include './forumdata/cache/cache_newreply.php';
[/code]

尋找

[code]
foreach(array('forumlinks', 'birthdays', 'supe_updateusers') as $key) {
[/code]

修改成

[code]
foreach(array('forumlinks', 'birthdays', 'supe_updateusers', 'foruminfo') as $key) {
[/code]


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

內容輸入

[code]
<div class='spaceborder spacebottom' style="width: {TABLEWIDTH}; clear: both; margin-top: 5px;">
<table cellspacing="0" cellpadding="4" width='100%'>
<tr class='header'><td>New Topic</td><td>New Reply</td></tr>
<tr>
<td class='smalltxt'>
<!--{loop $_DCACHE['newtopic'] $newtopic}-->
$newtopic[content]
<!--{/loop}-->
</td>
<td class='smalltxt'>
<!--{loop $_DCACHE['newreply'] $newreply}-->
$newreply[content]
<!--{/loop}-->
</td>
</tr>
</table>
</div>
[/code]


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

找到

[code]
<!--{if !empty($announcements)}-->
<div id="announcement">$announcements</div><script type="text/javascript">announcement();</script>
<!--{/if}-->
[/code]

在之後加入

[code]
{template foruminfo}
[/code]


8.) 然後進後台執行 [系統工具 > 更新緩存]

bestlong 發表於 2008-1-21 18:58

在 Disciz 6.0.0 版只有一個部分不同

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

尋找[code]showmessage($replymessage, "viewthread.php?tid=$tid&pid=$pid&page=".(@ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $ppp))."&extra=$extra#pid$pid");[/code]在之前加入[code]require DISCUZ_ROOT.'./include/cache.func.php';
updatecache('newreply');
updatecache('newtopic');[/code]
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.