|
簡單的說,就是每隔一段時間(自己設定的數據緩存時間),即使沒有新帖子,這個diy模塊所調用的帖子也會變。
02.JPG (95.57 KB, 下載次數: 56)
下載附件
2021-3-10 06:05 上傳
具體操作:
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'] : '';
復制代碼
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;"
- );
復制代碼
改為
- 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(),否則按原本的排序條件。 |
|