最后更新于2006年6月15日18:10时:修改了一下首页四格的位置,将其放在首页文字广告的下方,因为原来论坛没有放置文字广告,所以忽略了这个问题!之前安装的用户只需要重新安装第10步就可以了,代码已经更新,全新安装直接安装即可!
本贴根据帖子TOPLIST_首页四格_全Cache版FOR DZ4.1.0修改而来。
预览地址: http://xm.someweb.net/
或见附件:
插件说明:
1、增加最近比较热门的图片预览功能;
2、其他三格为:最新发表帖子,最新回复帖子,最热门帖子;
3、有升级数据库。
开始安装:
1、后台升级数据库
- INSERT INTO `cdb_settings` VALUES ('show_toplist', '1');
复制代码
2、编辑文件admin/setting.inc.php(后台显示功能设置内添加开关)
查找:
- showsetting('settings_nocacheheaders', 'settingsnew[nocacheheaders]', $settings['nocacheheaders'], 'radio');
复制代码
下面添加:
- showsetting('settings_show_toplist', 'settingsnew[show_toplist]', $settings['show_toplist'], 'radio');
复制代码
3、编辑语言包templates/default/admincp.lang.php(后台管理页面显示的文字)
查找:
- 'settings_forumjump_comment' => '选择“是”将在列表页面下部显示快捷跳转菜单。注意: 当分论坛很多时,本功能会严重加重服务器负担',
复制代码
下面添加:
- 'settings_show_toplist' => '显示首页四格',
- 'settings_show_toplist_comment' => '选则“是”将在首页显示首页四格',
复制代码
4、 include/cache.func.php
查找
- 'medals' => array('medals')
复制代码
上面加
- 'toplist' => array('newthread', 'newreply', 'topdigest', 'topviews'),//TOPLIST_首页四格_全Cache版_By oytktk
复制代码
继续查找
- case 'medals':
- $table = 'medals';
- $cols = 'medalid, name, image';
- $conditions = "WHERE available='1'";
- break;
复制代码
上面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- case 'newthread':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.dateline DESC LIMIT 0, 10";
- break;
- case 'newreply':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.replies>0 and t.displayorder!='-1' ORDER BY t.lastpost DESC LIMIT 0, 10";
- break;
- case 'topdigest':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.digest, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE digest>0 ORDER BY rand() LIMIT 0, 10";
- break;
-
- case 'topviews':
- $table = 'threads t';
- $view = rand(1,3)==1 ? 'views' : 'replies';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.$view DESC LIMIT 0, 10";
- break;
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
复制代码
再找:
- case 'settings':
- $data['qihoo_links'] = array();
- while($setting = $db->fetch_array($query))
复制代码
上面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- case 'newthread':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['subjectc'] = cutstr($topthread['subject'], 28);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'newreply':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['subjectc'] = cutstr($topthread['subject'], 26);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'topdigest':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $digest = array('1'=>'[Ⅰ]','2'=>'[Ⅱ]','3'=>'[Ⅲ]');
- $topthread['subjectc'] = $digest[$topthread['digest']]."-".cutstr($topthread['subject'], 23);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'topviews':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['subjectc'] = cutstr($topthread['subject'], 32);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
复制代码
5、 include/newthread.inc.php
查找
- updatepostcredits('+', $discuz_uid, $postcredits);
复制代码
下面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
复制代码
6、 include/newreply.inc.php
查找
- updatepostcredits('+', $discuz_uid, $replycredits);
复制代码
下面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
复制代码
7、include/editpost.inc.php
查找
- updatepostcredits('-', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits));
复制代码
下面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
复制代码
8、index.php
查找
- $forumlist = $catforumlist = $forums = $catforums = $categories = $collapse = array();
复制代码
下面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'category_hk2 ') === FALSE) {
- $categorys_hk2 = 'collapsed_no.gif';
- $collapse['category_hk2'] = '';
- } else {
- $categorys_hk2 = 'collapsed_yes.gif';
- $collapse['category_hk2'] = 'display: none';
- }
-
- if($categorys_hk2 == 'collapsed_no.gif'){
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_toplist.php';
- $toplistloop = $_DCACHE['newthread'];
- }
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
复制代码
9、topicadmin.php
查找
- showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'),
复制代码
上面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
复制代码
10、templates/default/index.htm
查找
- <!--{if !empty($advlist['text'])}--><div class="maintable"><table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">$advlist[text]</table><br></div><!--{/if}-->
复制代码
在下面加
- <!--{if empty($gid)}-->
- <!--{if $show_toplist}-->
- <div class="maintable">
- {template toplist}
- <br>
- </div>
- <!--{/if}-->
- <!--{/if}-->
复制代码
11、下载附件toplist.rar上传至相应的目录内即可!其中topview文件夹上传至论坛跟目录,toplist.htm文件上传至templates/default
12、到后台更新缓存(务必!!!)
其他需要自己再做些修改,自己设置吧!!
注意:预览的图片经本人只测试了支持.jpg格式,不支持.gif格式!
13、一些供选择的小修改:
⑴、需要缩放按钮的朋友修改以下地方:
在toplist.htm里面查找
- <td colspan="4" align="center" class="header">
复制代码
后面加
- <p align="left"><a href="index.php" onclick="toggle_collapse
- ('category_hk2');"><img id="category_hk2_img" src="{IMGDIR}/$categorys_hk2" align="right" border="0"></a>
复制代码
⑵、如果想每个格子里面显示的条数为自己设定值得话,请修改如下地方:(前提是步骤12以前都已经完成)
打开include/cache.func.php
查找
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.dateline DESC LIMIT 0, 10";
复制代码
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.replies>0 and t.displayorder!='-1' ORDER BY t.lastpost DESC LIMIT 0, 10";
复制代码
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE digest>0 ORDER BY rand() LIMIT 0, 10";
复制代码
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.$view DESC LIMIT 0, 10";
复制代码
分别将里面的
替换成你想要数字(即显示的条数)。
如果不想显示某个子板块的帖子:
可以在cache.func.php里面把新加入的那段代码中4个ORDER BY前全部加上and f.fid!=''(引号里是隐藏帖子所在论坛的fid号,例如:and f.fid!='3')更新缓存就行了.
他人提供,本人未作测试,自己试试看吧!!!
[ 本帖最后由 weaver2000 于 2006-6-15 11:27 编辑 ] |