插件名称: 首页热门贴For D25 & D25 SP1 Cache
作 者: 原作者
数据升级:有
修改文件: inlude/cache.php,index.php
修改模板: 添加一个模板,修改index.htm
最后发表日期:2005.4
演示
http://www.51happy365.com/bbs
1.将附件上传到templates/default目录下
2.修改inlude/cache.php
找到
- 'index' => array('announcements','onlinelist', 'forumlinks'),
复制代码
修改为
- 'index' => array('announcements','onlinelist', 'forumlinks','topview','topreply','toppostnum'),//首页热门贴
复制代码
找到
- case ranks:
- $table = $GLOBALS['table_ranks'];
- $cols='ranktitle,postshigher,stars';
- $conditions = "WHERE 1 ORDER BY postshigher desc";
- break;
复制代码
其下加
- ////////////////首页热门帖///////////////
- case topview:
- $table = $GLOBALS['table_threads'];
- $cols='dateline,tid,subject,author,views,replies';
- $conditions = "ORDER BY views DESC LIMIT 0,10";
- break;
- case topreply:
- $table = $GLOBALS['table_threads'];
- $cols='dateline,tid,subject,author,views,replies';
- $conditions = "ORDER BY replies DESC LIMIT 0,10";
- break;
- case toppostnum:
- $table = $GLOBALS['table_members'];
- $cols='username, uid, postnum';
- $conditions = "ORDER BY postnum DESC LIMIT 0, 10";
- break;
- ////////////////首页热门帖///////////////
复制代码
找到
- if (!$table) return;
- $data = array();
- $query = $db->query("SELECT $cols FROM $table $conditions");
- switch($cachename) {
复制代码
其下加
- ////////////////首页热门帖///////////////
- case topview:
- while($thread=$db->fetch_array($query)) { $thread[subject0]=$thread[subject];
- $thread['subject'] = cutstr($thread['subject'], 35);//35为显示的字长,请按需要更改
- $data[]=$thread;}
- break;
- case topreply:
- while($thread=$db->fetch_array($query)) { $thread[subject0]=$thread[subject];
- $thread['subject'] = cutstr($thread['subject'], 35);//35为显示的字长,请按需要更改
- $data[]=$thread;}
- break;
- case toppostnum:
- $notime=time();
- while($toppostnums=$db->fetch_array($query)) {$toppostnums['uptime']=$notime;$data[]=$toppostnums;}
- break;
- ////////////////首页热门帖///////////////
复制代码
3.修改index.php
找到
- if(empty($gid)) {
- $navigation = $navtitle = '';
复制代码
其上加
- ///////////////////////首页热门贴HACK FOR DISCUZ2.5 ---- http://www.xianlai.com//////////
- $hack_subject_len=35;
- $hack_subject_num=10;
- $cachetime=3600*10;//10小时更新一次,可根据需要修改
- $upcache=$_DCACHE['toppostnum']['0']['uptime'];//echo"$upcache;$timestamp";
- if(($timestamp-$upcache)>$cachetime){$indexflag=1;require_once DISCUZ_ROOT.'./include/cache.php';
- updatecache('toppostnum'); }
- $hack_newthreads_threadlist = array();
- $thread = array();
- $query = $db->query("SELECT dateline,tid,subject,author,views,replies FROM $table_threads ORDER BY dateline DESC LIMIT 0, $hack_subject_num");
- while($thread = $db->fetch_array($query)) {
- $thread[subject0]=$thread[subject];
- $thread['subject'] = cutstr($thread['subject'], $hack_subject_len);
- $hack_newthreads_threadlist[] = $thread;
- }
- ///////////////////////HACK END///////
复制代码
4.编辑模板index.htm
找到
- <!--{if !empty($newpmexists)}-->
- {template pmprompt}
- <!--{/if}-->
复制代码
其下加
- <!-- Hot hack -->
- {template hack_index_hot_topics}
- <!-- Hot hack end -->
复制代码
[ Last edited by freddy on 2005-4-21 at 11:30 ]
[ 本帖最后由 freddy 于 2005-7-7 15:43 编辑 ] |