===================================================================
===================================================================
===================================================================
===================================================================
這個只適用 4.1 想要 4.0 請到 4.0 插件區找找
若板區置頂太多 可設定顯示一條公告
若置頂太少 又可設定顯示多幾條公告
完全讀取 cache 不會增加數據庫查詢
===================================================================
修改檔案 ( 修改前請先備份 )
include/cache.func.php
admin/forums.inc.php
forumdisplay.php
templates/default/forumdisplay.htm ( 其它風格有這份檔亦要修改 )
templates/default/admincp.lang.php
( 完成後緊記 更新緩存 )
===================================================================
數據庫升級
- ALTER TABLE `cdb_forums` ADD `fourmannnum` MEDIUMINT( 8 ) NOT NULL DEFAULT '1' ;
复制代码
===================================================================
include/cache.func.php
找
- $conditions = "LEFT JOIN {$tablepre}members m ON m.username=a.author WHERE a.starttime<='$timestamp' ORDER BY a.displayorder, a.starttime DESC, a.id DESC LIMIT 1";
复制代码
改為
- $conditions = "LEFT JOIN {$tablepre}members m ON m.username=a.author WHERE a.starttime<='$timestamp' ORDER BY a.displayorder, a.starttime DESC, a.id DESC LIMIT 0, 10";
复制代码
再找
- case 'announcements_forum':
- if($data = $db->fetch_array($query)) {
- $data['authorid'] = intval($data['authorid']);
- $data['message'] = cutstr(strip_tags($data['message']), 18);
- } else {
- $data = array();
- }
- break;
复制代码 改為
- case 'announcements_forum':
- while($anndata = $db->fetch_array($query)) {
- $anndata['authorid'] = intval($anndata['authorid']);
- $anndata['message'] = cutstr(strip_tags($anndata['message']), 30);
- $data[] = $anndata;
- }
- break;
复制代码
===================================================================
forumdisplay.php
找
- if($page == 1) {
- if($_DCACHE['announcements_forum']) {
- $announcement = $_DCACHE['announcements_forum'];
- $announcement['starttime'] = gmdate($dateformat, $announcement['starttime'] + ($timeoffset * 3600));
- } else {
- $announcement = NULL;
- }
- }
复制代码 改為
- if($page == 1) {
- if($_DCACHE['announcements_forum']) {
- $fourmannnum = $forum['fourmannnum'];
- $announcementnum = 0;
- foreach($_DCACHE['announcements_forum'] as $announcement) {
- $announcementnum++;
- if ($announcementnum <= $fourmannnum) {
- $announcement['starttime'] = gmdate($dateformat, $announcement['starttime'] + ($timeoffset * 3600));
- $announcement_list[] = $announcement;
- }
- }
- } else {
- $announcement = NULL;
- }
- }
复制代码
===================================================================
templates/default/forumdisplay.htm ( 其它風格有這份檔亦要修改 )
找
- <!--{if $page == 1 && !empty($announcement)}-->
- <tr>
- <td class="altbg2" align="center"><a href="announcement.php?id=$announcement[id]#$announcement[id]" target="_blank"><img src="{IMGDIR}/lock_folder.gif" border="0"></a></td>
- <td class="altbg2" colspan="2" onMouseOver="this.className='altbg1'" onMouseOut="this.className='altbg2'">{lang announcement}: <a href="announcement.php?id=$announcement[id]#$announcement[id]">$announcement[subject]</a></td>
- <td class="altbg1" align="center"><a href="viewpro.php?uid=$announcement[authorid]">$announcement[author]</a><br><span class="smalltxt">$announcement[starttime]</span></td>
- <td class="altbg2" align="center">-</td>
- <td class="altbg1" align="center">-</td>
- <td class="altbg2" align="center">-</td>
- </tr>
- <!--{/if}-->
复制代码
改為
- <!--{if $page == 1 && count($announcement_list)}-->
- <!--{loop $announcement_list $key $announcement}-->
- <tr>
- <td class="altbg2" align="center"><a href="announcement.php?id=$announcement[id]#$announcement[id]" target="_blank"><img src="{IMGDIR}/lock_folder.gif" border="0"></a></td>
- <td class="altbg2" colspan="2" onMouseOver="this.className='altbg1'" onMouseOut="this.className='altbg2'">{lang announcement}: <a href="announcement.php?id=$announcement[id]#$announcement[id]">$announcement[subject]</a></td>
- <td class="altbg1" align="center"><a href="viewpro.php?uid=$announcement[authorid]">$announcement[author]</a><br><span class="smalltxt">$announcement[starttime]</span></td>
- <td class="altbg2" align="center">-</td>
- <td class="altbg1" align="center">-</td>
- <td class="altbg2" align="center">-</td>
- </tr>
- <!--{/loop}-->
- <!--{/if}-->
复制代码
===================================================================
admin/forums.inc.php
找
- showsetting('forums_edit_edit_rules', '', '', '<input type="radio" name="alloweditrulesnew" value="0" '.$checkrules[0].'> '.$lang['forums_edit_edit_rules_html_none'].'<br><input type="radio" name="alloweditrulesnew" value="1" '.$checkrules[1].'> '.$lang['forums_edit_edit_rules_html_no'].'<br><input type="radio" name="alloweditrulesnew" value="2" '.$checkrules[2].'> '.$lang['forums_edit_edit_rules_html_yes']);
复制代码
之下加入
- showsetting('forums_edit_fourmannnum', 'fourmannnumnew', $forum['fourmannnum'], 'text');
复制代码
再找
alloweditrules='$alloweditrulesnew',
後面加入
fourmannnum='$fourmannnumnew',
加入完成如下
alloweditrules='$alloweditrulesnew', fourmannnum='$fourmannnumnew',
===================================================================
templates/default/admincp.lang.php
找
- 'forums_edit_edit_rules_html_none' => '不允許版主修改',
复制代码
之下加入
- 'forums_edit_fourmannnum' => '公告條數',
- 'forums_edit_fourmannnum_comment' => '本版區顯示多少條論壇公告',
复制代码
===================================================================
[ 本帖最后由 別問我是誰 于 2006-4-28 06:59 编辑 ] |