PDA

View Full Version : Is there a way make an RSS feed from a single thread?


tribedude
04-12-2010, 05:33 PM
Is there a way to make an RSS feed from a single thread on my board? Or is there a mod for 3.8x available to do this? (I have searched to no avail BTW)

I know you can create RSS feeds from an entire board (which seems like the default), but what I really want to do is create a RSS feed from a specific thread on our board (which I hope to feed into a wordpress blog at some point).

Thanks,

adbox
07-01-2012, 08:45 PM
I also am looking for this. Anyone?

Looking for this too. Cheers

--------------- Added 1341182211 at 1341182211 ---------------

Here's an attempt at a custom solution. It could use some work though.

Add this into a php file in your forum directory and access it by typing the following into your browser:

file.php?tid=thread-id-here


<?php
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./cbparser.php');
require_once('./includes/class_bbcode.php');
require_once('./includes/class_bbcode_alt.php');
header("Content-Type: application/rss+xml; charset=UTF-8");
echo "<?xml version='1.0' encoding='UTF-8'?>";
?>
<rss version="2.0">
<channel>
<title>Thread Specific Feed</title>
<link>http://www.hatnohat.com/</link>
<description>Marketers &amp; Developers Membership Community</description>
<language>en-us</language>
<copyright>Copyright (C) 2012 hatnohat.com</copyright>
<?php

// Convert BBCodes to their HTML equivalent
FUNCTION do_bbcode($text){
GLOBAL $lang_common, $FORUM_user;

IF (STRPOS($text, 'quote') !== FALSE){
$text = STR_REPLACE('[quote]', '</p><blockquote><div class="incqbox"><p>', $text);
$text = PREG_REPLACE('#\[quote=("|"|\'|)(.*)\\1\]#seU', '"</p><blockquote><div class=\"incqbox\"><h4>".str_replace(array(\'[\', \'\\"\'), array(\'[\', \'"\'), \'$2\')." ".$lang_common[\'wrote\'].":</h4><p>"', $text);
$text = PREG_REPLACE('#\[\/quote\]\s*#', '</p></div></blockquote><p>', $text);
}

$pattern = ARRAY('#\[b\](.*?)\[/b\]#s',
'#\[i\](.*?)\[/i\]#s',
'#\[u\](.*?)\[/u\]#s',
'#\[url\]([^\[]*?)\[/url\]#e',
'#\[url=([^\[]*?)\](.*?)\[/url\]#e',
'#\[email\]([^\[]*?)\[/email\]#',
'#\[email=([^\[]*?)\](.*?)\[/email\]#',
'#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

$replace = ARRAY('<strong>$1</strong>',
'<em>$1</em>',
'<span class="bbu">$1</span>',
'handle_url_tag(\'$1\')',
'handle_url_tag(\'$1\', \'$2\')',
'<a href="mailto:$1">$1</a>',
'<a href="mailto:$1">$2</a>',
'<span style="color: $1">$2</span>');

$text = PREG_REPLACE($pattern, $replace, $text);

RETURN $text;
}


/////////////////////////////////////

// If the message contains a code tag we have to split it
// up (text within shouldn't be touched)
IF (STRPOS($text, '') !== FALSE && STRPOS($text, '') !== FALSE){
LIST($inside, $outside) = split_text($text, '', '');
$outside = ARRAY_MAP('ltrim', $outside);
$text = IMPLODE('<">', $outside);
}


$tid = $_GET['tid'];

if ($tid)
{

$query = "select * from hnh_post WHERE threadid='$tid' ORDER BY dateline DESC";
$result = mysql_query($query);
//echo mysql_num_rows($result); exit;
while ($array = mysql_fetch_array($result))
{
//echo 1;
$pid = $array['postid'];
$title = $array['title'];
$author = $array['username'];
$author_id = $array['userid'];
$author_link = "http://www.hatnohat.com/forum/member.php?u=2367";
$thread_link = "http://www.hatnohat.com/forum/showthread.php?threadid=$tid&amp;p=$pid";
$date = $array['dateline'];
$date = date('D, d M y H:i:s O', strtotime($date));
$text = bb2html($array['pagetext']);
$text = strip_tags($text,'<b><i>');

if (!$title)
{
$title = $text;
}
?>
<item>
<title><?php echo $title ?></title>
<description><![CDATA[<?php echo $text ?>]]></description>
<link><?php echo $thread_link; ?></link>
<pubDate><?php echo $date ?></pubDate>
</item>
<?php
}
}

?>
</channel>
</rss>