Zblog (non js) calls the method of discuz post

web front end four thousand two hundred and ninety-eight 4 years ago (2020-07-24)

Step 1: In the zblog Directory (in b2c theme For example, under the/zb_users/theme/b2c/include directory, create new empty files news01.html and news02.html.


Step 2: Copy the following code and save it as news. php, and upload it to the source/include/cron/directory of the discuz program.

 <? php if(!defined('IN_DISCUZ')) { exit('Access Denied'); } //Separate id (modify fid according to your needs, and the number 5 at the end represents the number of calls) $query01 = DB::query("SELECT tid,subject,dateline FROM ".DB::table('forum_thread'). " where fid=71 AND displayorder>=0 order by dateline desc limit 0,5"); while ($value = DB::fetch($query01)) { $txtstr01.="<dd><span>[". date ("m month d day", $value ['dateline ']) "]</span><a href='/bbs/forum.php?mod=viewthread&tid=".$ value['tid']. "&extra=page%3D1' target='_blank' title='".$ value['subject']. "'>".$ value['subject']. "</a></dd>\n"; } file_put_contents('../zb_users/theme/b2c/include/news01.html', $txtstr01); //Multiple IDs (modify fid according to your needs, and the number 5 at the end represents the number of calls) $query02 = DB::query("SELECT tid,subject,dateline FROM ".DB::table('forum_thread'). " where fid in (51,52,55,66,68,69,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103) AND displayorder>=0 order by dateline desc limit 0,5"); while ($value = DB::fetch($query02)) { $txtstr02.="<dd><span>[". date ("m month d day", $value ['dateline ']) "]</span><a href='/bbs/forum.php?mod=viewthread&tid=".$ value['tid']. "&extra=page%3D1' target='_blank' title='".$ value['subject']. "'>".$ value['subject']. "</a></dd>\n"; } file_put_contents('../zb_users/theme/b2c/include/news02.html', $txtstr02); ?>


Step 3: Log in to dishuz background management - Tools - Schedule Task, create a new task named "zblog call post", check and submit it in the "Available" column.

 discuz01.png


Step 4: Modify the time of the scheduled task according to your needs. It is executed every 5 minutes by default.

 discuz02.png


After setting, you can call it in the zblog template file. The calling codes are: {file_get_contents ('replace your web address here/zb_users/theme/b2c/include/news01. html ')} and {file_get_contents ('replace your web address here/zb_users/theme/b2c/include/news02. html')}