- UID
- 1
- 阅读权限
- 200
- 注册时间
- 2022-3-27
- 积分
- 2584
- 最后登录
- 2025-2-7
TA的每日心情 | 擦汗 2023-7-12 20:55 |
---|
签到天数: 8 天 连续签到: 8 天 [LV.3]偶尔看看II
管理员
- 积分
- 2584
   
|
简单来说,就是每隔一段时间(自己设定的数据缓存时间),即使没有新帖子,这个diy模块所调用的帖子也会变。
方法:加个选项,然后查询数据的时候把这个选项作为一个条件,选它就按它来调用。
具体操作:
1、打开/source/class/block/forum/block_threadhot.php,查找:
- array('recommends', 'threadlist_orderby_recommends'),
复制代码
在下边添加:
2、打开/source/class/block/forum/block_thread.php,查找:
- $orderby = isset($parameter['orderby']) ? (in_array($parameter['orderby'],array('lastpost','dateline','replies','views','heats','recommends')) ? $parameter['orderby'] : 'lastpost') : 'lastpost';
- $lastposter = !empty($parameter['lastposter']) ? $parameter['lastposter'] : '';
复制代码
修改为:
- $orderby = isset($parameter['orderby']) ? (in_array($parameter['orderby'],array('lastpost','dateline','replies','views','heats','recommends','rands')) ? $parameter['orderby'] : 'lastpost') : 'lastpost';
- $lastposter = !empty($parameter['lastposter']) ? $parameter['lastposter'] : '';
复制代码
继续查找:
- $query = DB::query("SELECT DISTINCT t.*$sqlfield
- FROM `".DB::table('forum_thread')."` t
- $sqlfrom WHERE {$maxwhere}t.readperm='0'
- $sql
- AND t.displayorder>='0'
- ORDER BY t.$orderby DESC
- LIMIT $startrow,$items;"
- );
复制代码
修改为:
- if($orderby=='rands'){
- $query = DB::query("SELECT DISTINCT t.* $sqlfield FROM `".DB::table('forum_thread')."` t $sqlfrom WHERE {$maxwhere}t.readperm='0' $sql AND t.displayorder>='0' ORDER BY rand() LIMIT $startrow,$items;");
- }else{
- $query = DB::query("SELECT DISTINCT t.*$sqlfield
- FROM `".DB::table('forum_thread')."` t
- $sqlfrom WHERE {$maxwhere}t.readperm='0'
- $sql
- AND t.displayorder>='0'
- ORDER BY t.$orderby DESC
- LIMIT $startrow,$items;"
- );
- }
复制代码
就是在数据查询的外层加上了判断,如果是随机排序,查询里排序条件就用ORDER BY rand(),否则按原本的排序条件。 |
上一篇:Discuz! 修改”提示:作者被禁止或删除 内容自动屏蔽“下一篇:Discuz! 后台安全加固 防止恶意访问
|