Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 685

display recent posts

$
0
0
I think it would be useful for new and low volume boards to monitor new posts through a feed instead of all that drilling.  So, I've created a recentpost.php from the syndication.php file.  Here are the changes with context below:

Code:
$ diff -c syndication.php recentposts.php
*** syndication.php    2015-07-20 13:56:41.946689932 +0000
--- recentposts.php    2015-07-20 15:17:29.076654114 +0000
***************
*** 174,180 ****
 
 if(!empty($firstposts))
 {
!     $firstpostlist = "pid IN(".$db->escape_string(implode(',', $firstposts)).")";
 
     if($mybb->settings['enableattachments'] == 1)
     {
--- 174,180 ----
 
 if(!empty($firstposts))
 {
!     $firstpostlist = '';
 
     if($mybb->settings['enableattachments'] == 1)
     {
***************
*** 190,196 ****
         }
     }
 
!     $query = $db->simple_select("posts", "message, edittime, tid, fid, pid", $firstpostlist, array('order_by' => 'dateline', 'order_dir' => 'desc'));
     while($post = $db->fetch_array($query))
     {
         $parser_options = array(
--- 190,196 ----
         }
     }
 
!     $query = $db->simple_select("posts", "subject, message, edittime, tid, fid, pid, greatest(dateline, edittime) as lastsaved", $firstpostlist, array('order_by' => 'lastsaved', 'order_dir' => 'desc', 'limit' => $thread_limit));
     while($post = $db->fetch_array($query))
     {
         $parser_options = array(
***************
*** 225,230 ****
--- 225,234 ----
             }
         }
 
+         $items[$post['tid']]['title'] = $parser->parse_badwords($post['subject']);
+         if( !$items[$post['tid']]['link'] ) {
+             $items[$post['tid']]['link'] = $channel['link'].get_post_link($post['pid'] . "#pid" . $post['pid'], $post['tid']);
+         }
         $items[$post['tid']]['description'] = $parsed_message;
         $items[$post['tid']]['updated'] = $post['edittime'];
         $feedgenerator->add_item($items[$post['tid']]);

Hope that helps.

Viewing all articles
Browse latest Browse all 685

Trending Articles