Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

I guess it would be handy if someone would compare the two so people know the differences when they are trying to choose. I won't have time for a while, but if I get some I'll take a look. If yours is better, I'll switch myself. smile

27 (edited by daniel_jalkut 2005-06-28 20:59)

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Thanks for making the script available.  I am using the original alexkingorg version that started this thread.

One change I made was to (IMHO) de-uglify the content.  I find the "Topic: " line useless because it's already in the feed title, and the "Message: " prefix seems redundant to me.

I was also disappointed to see that the "encode_xml" routine in the script strips most of the interesting tags from the content.  This makes for, at least on my newsreader, and ugly chunk of text that has no newlines, etc.  I see in the script that it's actually inserting "\n" but that doesn't seem to make much difference to my newsreader (NetNewsWire on the Mac).

So I've got what I feel is much prettier output by simply omitting the "encode_xml" call.  What am I getting myself into by doing that? Is that going to wreak havoc on somebody else's news reader?

In case anybody feels like observing the content with my changes, here's an example from my site:

http://www.red-sweater.com/forums/rss.php

Thanks again for sharing this script!

28 (edited by alexkingorg 2005-06-29 01:25)

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Well, encode_xml encodes the content so the feed is valid. It could certainly be done in a more elegant way - it just takes someone with the time to do it.

For example, your feed is invalid:

http://feedvalidator.org/check.cgi?url= … %2Frss.php

29

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Just deciding to install one of these or wait for 1.3?

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Thanks Alex - I am just so naive to this RSS world that I don't know all the ground rules. Thanks for that feedvalidator link - I will see what I can do to make the text both beautiful and valid.  If I come up with something good, I'll be sure to share my results here!

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Update: I get the content I was expecting with the desired formatting simply by uncommenting an existing "content:encoded" output line that was in the script, and adding the required namespace reference to the rss header tag.

The feed now validates. Thanks again, Alex.  This has been a good introductory education about the RSS format.

In case anybody wants a copy of the modified rss.php file, I've made it available:

http://www.red-sweater.com/free/rss.zip

My previously posted feed is now using this and has the desired content formatting as well as being validated RSS:

http://www.red-sweater.com/forums/rss.php

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

I also appreciated Alex's advice on peppering the PunBB sources with RSS links.  I took that advice and also made some changes so that RSS auto-detect would work.  For instance, in Safari on the Mac, this causes a nice RSS button to appear next to the URL in the browser.

The basic gist of all these changes is to add a <link> tag at the top of each significant page, indicating to the browser or client application what the corresponding feed for the page is.

In viewforum.php, replace:

$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 1)
        message($lang_common['Bad request']);

with

$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 1)
        message($lang_common['Bad request']);  
?>
<link rel="alternate" type="application/rss+xml" title="XML" href="rss.php?fid=<?php echo $id ?>"/>
<?php

In viewtopic.php, basically the same thing:

if ($id < 1 && $pid < 1)
        message($lang_common['Bad request']);

with

if ($id < 1 && $pid < 1)
        message($lang_common['Bad request']);
?>
<link rel="alternate" type="application/rss+xml" title="XML" href="rss.php?tid=<?php echo $id ?>"/>
<?php

and in index.php, to add an RSS autodetect for the entire forum, replace:

if ($pun_user['g_read_board'] == '0')
        message($lang_common['No view']);

with

if ($pun_user['g_read_board'] == '0')
        message($lang_common['No view']);
?>              
<link rel="alternate" type="application/rss+xml" title="XML" href="rss.php"/>
<?php

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

daniel_jalkut wrote:

Update: I get the content I was expecting with the desired formatting simply by uncommenting an existing "content:encoded" output line that was in the script, and adding the required namespace reference to the rss header tag.

That's exactly what I meant by "having the time to do so". I'd created the "formatted" version, but didn't have time to track down the namspace reference issue so it didn't validate.

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

So, I'd like to access rss as the administrator.  Does someone have an rss.php already modified to do that?

thanks.

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

ok after that whole od replacement's and all could someone .zip that and put it for download!?

36

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

How do I install that php-file?

37

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Maybe it is basic knowledge, but I simply don't know how to install this mod for making rss-feeds. Can anyone please give me a hint.

The reason for wanting this mod is, that in the built-in rss-feed in pun I am missing the tags "pubdate", and I hope that this mod will contain this.

38

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

i always got : Fatal error: Call to a member function on a non-object in /home/.heather/coxis/guistyles.com/forum/include/parser.php on line 35

39

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Thanks a lot for this usefull mod

and to daniel_jalkut for the formatting correction as I was trying to do the same

it works very well wink

40

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

So I'm still getting "No Permission" because I have my forum closed off to non-members.

Did we ever come to a secure solution for this problem? By solution I mean RSS feeds for categories and forums for members only?

41 (edited by gdsingh 2006-04-10 01:49)

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

i am getting a

XML Parsing Error: not well-formed
Location: http://domain.com/forum/rss.php?tid=10
Line Number 1, Column 2:</channel>
-^

error when i try to get a topic feed.

any help would be appriciated, thanks.

42

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

masey wrote:

So I'm still getting "No Permission" because I have my forum closed off to non-members.

Did we ever come to a secure solution for this problem? By solution I mean RSS feeds for categories and forums for members only?

I've been looking all over for a solution.  Doesn't look like there is an easy one.

I don't allow guests to view my forum, so the rss.php can't get to it either.  I wish there was some way to pass authentication for the feed.

43

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

how to show poster?

it's just me...

44

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

faax wrote:

how to show poster?

huh?

45

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Rustin wrote:
faax wrote:

how to show poster?

huh?

I think he wants it to look similar to like this:

15 Most Recently Active Forum Topics
   1. So now it's wrong to be able t ... :: dbmasters :: Open Discussion
   2. closed caption mistakes             :: dbmasters :: George W.2
   3. chain mail support from Australia :: caddickj :: International Relations
   etc

As seen here:
http://freesquid.org/

// extern.php - modified for version 1.1.5
// Do something similar in whatever version you're using

//
// active2 (show recently active topics as 'subject(linked) : poster : forum_name(linked)') (HTML)
// Written by Dean Gardner, modified from the original in the punBB-1.1.5 extern.php file
// 
if ($_GET['action'] == 'active2')
{
    $order_by = ($_GET['action'] == 'active2') ? 't.last_post' : 't.posted';
    $forum_sql = '';

    // Was a forum ID supplied?
    if (isset($_GET['fid']))
    {
        $fid = intval($_GET['fid']);
        if (!empty($fid))
            $forum_sql = 'f.id='.$fid.' AND ';
    }


    // Should we output this as RSS?
    if (isset($_GET['type']) && strtoupper($_GET['type']) == 'RSS')
    {
        $rss_description = ($_GET['action'] == 'active2') ? $lang_extern['RSS Description Active'] : $lang_extern['RSS Description New'];
        $url_action = ($_GET['action'] == 'active2') ? '&action=new' : '';

        // Send XML/no cache headers
        header('Content-Type: text/xml');
        header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');


        // It's time for some syndication!
        echo '<?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'"?>'."\r\n";
        echo '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">'."\r\n";
        echo '<rss version="0.91">'."\r\n";
        echo '<channel>'."\r\n";
        echo "\t".'<title>'.pun_htmlspecialchars($pun_config['o_board_title']).'</title>'."\r\n";
        echo "\t".'<link>'.$pun_config['o_base_url'].'/</link>'."\r\n";
        echo "\t".'<description>'.pun_htmlspecialchars($rss_description.' '.$pun_config['o_board_title']).'</description>'."\r\n";
        echo "\t".'<language>en-us</language>'."\r\n";

        // Fetch 15 topics
        $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT 15') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

        while ($cur_topic = $db->fetch_assoc($result))
        {
            if ($pun_config['o_censoring'] == '1')
                $cur_topic['subject'] = censor_words($cur_topic['subject']);

            echo "\t".'<item>'."\r\n";
            echo "\t\t".'<title>'.pun_htmlspecialchars($cur_topic['subject']).'</title>'."\r\n";
            echo "\t\t".'<link>'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].$url_action.'</link>'."\r\n";
            echo "\t\t".'<description><![CDATA['.escape_cdata($lang_extern['Forum'].': <a href="'.$pun_config['o_base_url'].'/viewforum.php?id='.$cur_topic['fid'].'" target="_blank">'.$cur_topic['forum_name'].'</a><br />'."\r\n".$lang_extern['Author'].': '.$cur_topic['poster'].'<br />'."\r\n".$lang_extern['Posted'].': '.date('r', $cur_topic['posted']).'<br />'."\r\n".$lang_extern['Last post'].': '.date('r', $cur_topic['last_post'])).']]></description>'."\r\n";
            echo "\t".'</item>'."\r\n";
        }

        echo '</channel>'."\r\n";
        echo '</rss>';
    }




    // Output regular HTML
    else
    {
        echo '<ol>'."\n";
        $show = intval($_GET['show']);
        if ($show < 1 || $show > 50)
            $show = 15;

        // Fetch $show topics
                $result = $db->query('SELECT t.id, t.subject, t.last_post, t.last_post_id, t.last_poster, t.forum_id, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

        while ($cur_topic = $db->fetch_assoc($result))
        {
            if ($pun_config['o_censoring'] == '1')
                $cur_topic['subject'] = censor_words($cur_topic['subject']);

            if (pun_strlen($cur_topic['subject']) > $max_subject_length)
                $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
            else
                $subject_truncated = $cur_topic['subject'];

            echo '<li><a class="topic" href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a> <span class="block"><span class="dots">:: </span><b>'.$cur_topic['last_poster'].'</b> :: <a href="'.$pun_config['o_base_url'].'/viewforum.php?id='.$cur_topic['forum_id'].'">'.$cur_topic['forum_name'].'</a></span></li>'."\n";
        }
        echo '</ol>'."\n";
    }

    exit;
}

46

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

i don't need "smilar" like this... see post located here [url]http://punbb.org/forums/viewtopic.php?pid=67268#p67268[url]there is my rss.php ... so i need something in format like this

TOPIC NAME
Author: USERNAME wrote: MESSAGE

i have done with TOPICNAME and MESSAGE line but how to add author USERNAME ?
sorry about my bad english hope to understeand

it's just me...

47 (edited by montom 2006-08-20 22:23)

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

Also, clicking on the link to a post does not scroll the page down to the post's anchor.

The link is missing a "p" after the "#" so...

In rss.php replace:

$link = $pun_config['o_base_url'].'/viewtopic.php?pid='.strval($cur['id']).'#'.strval($cur['id']);

with:

$link = $pun_config['o_base_url'].'/viewtopic.php?pid='.strval($cur['id']).'#p'.strval($cur['id']);

48

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

faax wrote:

i don't need "smilar" like this... see post located here [url]http://punbb.org/forums/viewtopic.php?pid=67268#p67268[url]there is my rss.php ... so i need something in format like this

TOPIC NAME
Author: USERNAME wrote: MESSAGE

i have done with TOPICNAME and MESSAGE line but how to add author USERNAME ?
sorry about my bad english hope to understeand

how about this?

                $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_poster, f.id AS fid, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
        
        while ($cur_topic = $db->fetch_assoc($result))
        {
            if ($pun_config['o_censoring'] == '1')
                $cur_topic['subject'] = censor_words($cur_topic['subject']);

            if (pun_strlen($cur_topic['subject']) > $max_subject_length)
                $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
            else
                $subject_truncated = $cur_topic['subject'];

            echo '<li><a class="topic" href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a>- '.$cur_topic['last_poster'].' [Forum: <a href="'.$pun_config['o_base_url'].'/viewforum.php?id='.$cur_topic['fid'].'">'.$cur_topic['forum_name'].'</a>]</li>'."\n";
        }

49

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

will RSS feed capabilites be built into 1.3 as a core feature?
i.e. should I wait a bit for this???

Re: RSS Feeds for Categories, Forums, Topics and Latest Posts

phatax wrote:

will RSS feed capabilites be built into 1.3 as a core feature?
i.e. should I wait a bit for this???

RSS feeds are already available for the entire board and individual forums through extern.php in 1.2.x. RSS feeds for individual topics will be included in 1.3.

Looking for a certain modification for your forum? Please take a look here before posting.