演示: http://www.8talk.net/bbs/
作者:凡人·八度空间论坛 (friends@8talk.net)
安装需求:Discuz 2.5F/2.5FSP1
安装程度:容易
上传附件:announcement_build0702.rar
修改文件:
/
- forumdisplay.php
/admin/
- announcements.php
/include/
- cache.php
/templates/
- forumdisplay.htm
技术支持: 无需
插件功能:根据个别论坛发布公告,公告将以滚动方式显示在所选择的论坛上。可以选择多个板块,只有所有论坛公告将在所有论坛和主页显示,其余将只在所选择的论坛显示,没有选择任何论坛的公告将默认为所有论坛公告。
1。首先到后台数据库升级数据库:
- ALTER TABLE `cdb_announcements` ADD `forumid` TINYTEXT NOT NULL AFTER `id` ;
复制代码
2。打开forumdisplay.php:
查寻:
- $announcement_list = array();
- if($page == 1 && $_DCACHE['announcements_forum']) {
- foreach($_DCACHE['announcements_forum'] as $ann) {
- $ann['authorencode'] = rawurlencode($ann['author']);
- $ann['starttime'] = gmdate("$dateformat $timeformat", $ann['starttime'] + ($timeoffset * 3600));
- $announcement_list[] = $ann ;
- }
- }
复制代码
替换成:
- $announcements = '';
- if($_DCACHE['announcements_forum']) {
- $space = '';
- foreach($_DCACHE['announcements_forum'] as $announcement) {
- if (strstr($announcement[forumid], "\t$fid\t") || $announcement[forumid] == ''){
- if($timestamp >= $announcement['starttime'] && ($timestamp <= $announcement['endtime'] || !$announcement['endtime'])) {
- if ($announcement['posturl']){
- $announcements .= $space.'<a href="'.$announcement['posturl'].'" target="_blank"><span class="bold">'.$announcement['subject'].'</span> '.
- '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</a>';
- }else{
- $announcements .= $space.'<a href="announcement.php?id='.$announcement['id'].'#'.$announcement['id'].'" target="_blank"><span class="bold">'.$announcement['subject'].'</span> '.
- '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</a>';
- }
- $space = ' ';
- }
- }
- }
- }
复制代码
3。打开include/cache.php:
查寻:
- $conditions = "ORDER BY displayorder ASC, starttime DESC";
复制代码
替换成:
- $conditions = "WHERE forumid='' ORDER BY displayorder ASC, starttime DESC";
复制代码
查寻:
- $cols = " id, author, posturl, subject,starttime";
复制代码
替换成:
- $cols = " id, forumid, author, posturl, subject,starttime";
复制代码
查寻:
- $conditions = "ORDER BY displayorder ASC, starttime DESC LIMIT 0, $ann_num";
复制代码
替换成:
- $conditions = "ORDER BY displayorder ASC, starttime DESC";
复制代码
4。打开templates/default/forumdisplay.htm:
查寻并删除:
- <!--{if $page == 1 && count($announcement_list)}-->
- <!--{loop $announcement_list $key $announcement}-->
- <tr>
- <!--{if !$announcement[posturl]}-->
- <td width="4%" align="center" bgcolor="{ALTBG2}"><a href="announcement.php?id=$announcement[id]#$announcement[id]" target="_blank"><img src="{IMGDIR}/announcement.gif" border="0"></a></td>
- <td bgcolor="{ALTBG2}" colspan="2" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'"><B>{lang
- announcement}$announcement[id] :</B> <a href="announcement.php?id=$announcement[id]#$announcement[id]">$announcement[subject]</a></td>
- <!--{else}-->
- <td bgcolor="{ALTBG2}" align="center"><a href="$announcement[posturl]" target="_blank"><img src="{IMGDIR}/announcement.gif" border="0"></a></td>
- <td bgcolor="{ALTBG2}" colspan="2" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'"><B>{lang
- announcement}$announcement[id] :</B> <a href="$announcement[posturl]"target="_blank">$announcement[subject]</a></td>
- <!--{/if}-->
- <td bgcolor="{ALTBG1}" align="center"><a href="viewpro.php?username=$announcement[authorencode]">$announcement[author]</a></td>
- <td bgcolor="{ALTBG2}" align="center">-</td>
- <td bgcolor="{ALTBG1}" align="center">-</td>
- <td bgcolor="{ALTBG2}" align="center" class="smalltxt">$announcement[starttime]<br>
- $announcement[message]</td>
- </tr>
- <!--{/loop}-->
- <!--{/if}-->
复制代码
查寻:
- <tr class="header">
- <td colspan="3" align="center">{lang subject}</td>
- <td width="14%" align="center" nowrap>{lang author}</td>
- <td width="6%" align="center" nowrap>{lang replies}</td>
- <td width="6%" align="center" nowrap>{lang views}</td>
- <td width="19%" align="center">{lang lastpost}</td>
- </tr>
复制代码
在上面加入:
- <!--{if !empty($announcement)}-->
- <tr class="header">
- <td colspan="7" background="{IMGDIR}/bg1.gif" align="center">{lang announcement}</td>
- </tr>
- <tr bgcolor="{ALTBG2}" align="center">
- <td colspan="7" align="center">
- <!--{if empty($announcements)}-->
- {lang index_noannouncement}
- <!--{else}-->
- <marquee direction="left" scrollamount="3" onMouseOver="this.stop();" onMouseOut="this.start();">
- $announcements
- </marquee>
- <!--{/if}-->
- </td></tr>
- <!--{/if}-->
复制代码
5。上传附件里的3个文件,分别为:admin/announcements.php和admin/tpl/announcements_main.php,admin/tpl/announcements_edit.php到相应的目录
6。到后台更新公告及缓存。
完成。祝好运。。
以上安装方法是根据Discuz 2.5SP1 Build 0401版本进行。
由于市面上较少更改后台公告管理的Hack加上时间关系无法整理帖子,所以我只提供直接的文件覆盖方法。
[ 本帖最后由 8度空间 于 2005-7-4 02:51 编辑 ] |