- 積分
- 3569
- 金幣
- 351 個(gè)
- 社區(qū)幣
- 0 元
功行圓滿
- 貢獻(xiàn)
- 23 點(diǎn)
- 金幣
- 351 個(gè)
|
簡(jiǎn)單的說(shuō),就是每隔一段時(shí)間(自己設(shè)定的數(shù)據(jù)緩存時(shí)間),即使沒(méi)有新帖子,這個(gè)diy模塊所調(diào)用的帖子也會(huì)變。
02.JPG (95.57 KB, 下載次數(shù): 34)
下載附件
2021-3-10 06:05 上傳
具體操作:
1.打開(kāi)/source/class/block/forum/block_threadhot.php,找到
- array('recommends', 'threadlist_orderby_recommends'),
復(fù)制代碼
之下增加
- array('rands', '隨機(jī)'),
復(fù)制代碼
2.打開(kāi)/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'] : '';
復(fù)制代碼
改為
- $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'] : '';
復(fù)制代碼
3.找到
- $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;"
- );
復(fù)制代碼
改為
- 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;"
- );
- }
復(fù)制代碼
就是在數(shù)據(jù)查詢的外層加上了判斷,如果是隨機(jī)排序,查詢里排序條件就用ORDER BY rand(),否則按原本的排序條件。 |
|