Discuz!X版块导航显示本版今日发帖数(修改方法)
Discuz!X版块导航显示版块对应今日发帖数演示:http://www.wenliren.com/forum.php
修改方法(以Discuz!X2为例):
1.以文本形式打开文件“source/function/function_forumlist.php”;
2.查找到如下代码:
if(!$forum['status'] && !$showhide) {
continue;
}
3.在其后增加如下代码:
$todayposts = DB::result_first("select todayposts from " .DB::table('forum_forum'). " where fid = '$forum'");
4.继续查找如下打码:
if($arrayformat) {
$forumlist[$forum['fid']]['name'] = $forum['name'];
} else {
$forumlist .= $groupselectable ? '<option value="'.($evalue ? 'gid_' : '').$forum['fid'].'" class="bold">--'.$forum['name'].'</option>' : '</optgroup><optgroup label="--'.$forum['name'].'">';
}
$visible[$forum['fid']] = true;
} elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$_G\t")) && (!$special || (substr($forum['allowpostspecial'], -$special, 1)))) {
if($arrayformat) {
$forumlist[$forum['fup']]['sub'][$forum['fid']] = $forum['name'];
} else {
$forumlist .= '<option value="'.($evalue ? 'fid_' : '').$forum['fid'].'"'.$selected.'>'.$forum['name'].'</option>';
}
5.将其替换为如下代码:
if($arrayformat) {
$forumlist[$forum['fid']]['name'] = $forum['name'];
} else {
$forumlist .= $groupselectable ? '<option value="'.($evalue ? 'gid_' : '').$forum['fid'].'" class="bold">--'.$forum['name'].'</option>' : '</optgroup><optgroup label="--'.$forum['name'].'">';
}
$visible[$forum['fid']] = true;
} elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$_G\t")) && (!$special || (substr($forum['allowpostspecial'], -$special, 1)))) {
if($arrayformat){
if($todayposts==0) {
$forumlist[$forum['fup']]['sub'][$forum['fid']] = $forum['name'];
} else {
$forumlist[$forum['fup']]['sub'][$forum['fid']] = $forum['name'].'<font color=#FFC468>('.$todayposts.')</font>';
}
}else {
$forumlist .= '<option value="'.($evalue ? 'fid_' : '').$forum['fid'].'"'.$selected.'>'.$forum['name'].'</option>';
}
6.保存,上传到原目录并覆盖文件(覆盖前做好备份),更新网站缓存,即可!
说明:
1)如果要修改“今日贴数”的颜色,请在第5步倒数第4行修改对应的“<font color=#FFC468>”为其他索引颜色值即可;
2)此修改对Discuz!X2默认模板或者其他模板也有效,请参考修改对应模板对应目录下的文件即可(默认模板的效果在版块页面开启版块导航后可见);
3)为避免出现不可预知的问题,上传覆盖前请务必做好原文件备份。
演示效果(本站):
演示效果(默认模板,理论上显示位置):
修改后的参考文件(下载后可直接覆盖):
页:
[1]