2012-07-11, 08:43 AM
Hi,
one of our users asked for RSS notification of latest posts instead of first posts in a thread. I changed syndication.php to do so and want to share it. Maybe someone upgrades it (e.g. adding Configuration on the syndication page).
Enjoy
one of our users asked for RSS notification of latest posts instead of first posts in a thread. I changed syndication.php to do so and want to share it. Maybe someone upgrades it (e.g. adding Configuration on the syndication page).
Enjoy
diff --git a/htdocs/syndication.php b/htdocs/syndication.php
index b70070d..aec1961 100644
--- a/htdocs/syndication.php
+++ b/htdocs/syndication.php
@@ -144,10 +144,36 @@ while($thread = $db->fetch_array($query))
if(!empty($firstposts))
{
+
+ /* default - first post of every thread */
$firstpostlist = "pid IN(".$db->escape_string(implode(',', $firstposts)).")";
$query = $db->simple_select("posts", "message, edittime, tid, fid, pid", $firstpostlist, array('order_by' => 'dateline', 'order_dir' => 'desc'));
+
+ /* "syndication.php?feedtype=last" - last (instead of first) post of every thread */
+ if(isset($mybb->input['feedtype']) && $mybb->input['feedtype']=='last')
+ {
+ $query = $db->query(
+ "SELECT
+ subject, message, dateline, p.tid, fid, pid
+ FROM
+ posts p,
+ (SELECT tid, max(dateline) AS max_dateline FROM posts GROUP BY tid) tmp
+ WHERE
+ p.tid = tmp.tid && dateline = max_dateline;");
+ }
+
while($post = $db->fetch_array($query))
{
+ /* update the threads detail with details of last post */
+ if(isset($mybb->input['feedtype']) && $mybb->input['feedtype']=='last')
+ {
+ $items[$post['tid']] = array(
+ "title" => $parser->parse_badwords($post['subject']),
+ "link" => $channel['link'].get_post_link($post['pid'])."#pid${post['pid']}",
+ "date" => $post['dateline'],
+ );
+ }
+
$parser_options = array(
"allow_html" => $forumcache[$post['fid']]['allowhtml'],
"allow_mycode" => $forumcache[$post['fid']]['allowmycode'],
@@ -185,4 +211,4 @@ if(!empty($firstposts))
// Then output the feed XML.
$feedgenerator->output_feed();
-?>
\ No newline at end of file
+?>