Categories > TinyButStrong general >

RSS Feed from TBS Forum

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Tom
Date: 2005-11-13
Time: 20:16

RSS Feed from TBS Forum

Hi Skrol

I keep up to date with many projects using their RSS News Feeds in my browser local home page -- it would be excelllent to be able to always see the most recent tbs fORUM POSTINGS.

If there is already an RSS feed -- please advise me.

If not ;-)  here are some scripts I was making to learn TBS my making an RSS feed myself.  You or others on this forum probably can do much better, but if you want to save a little time - maybe these will help if others TBS users would also like RSS from the Forum.

NewMessagesRSS.php
<?
// for forum $version = '1.33' ;
/*
// -- Tom Henry -- donated code for RSS feed from TBS Forum Application
*/
//----------------------------
include_once('tbs_class.php') ;
$TBS = new clsTinyButStrong ;
//Connexion to the database
require('forum_cnx.php');
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('NewMessagesRSS.xml') ;
if( isset($numshow)){
$setlimit = "LIMIT $numshow ";
}
$TBS->MergeBlock('1st',$cnx_id,"SELECT * FROM t_forum_message ORDER BY msg_date DESC $setlimit");
mysql_close($cnx_id) ;
$TBS->Show() ;
?>

NewMessagesRSS.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
        <title>MyForum RSS Feed</title>
        <description>My TBS Forum News Fees in Rss 2.0</description>
        <link>http://www.tinybutstrong.com/</link>
        <item>
            <title>[1st.msg_subject;block=item]</title>
            <link>http://localhost/tbs/forum/RssMessage.php?id=[1st.msg_id]</link>
            <description>[1st.msg_email]</description>
            <pubDate>[1st.msg_date]</pubDate>
        </item>
</channel>
</rss>


And I made a little reader to view the posts that are made links in the above scripts:

RssMessage.php
<?
//----------------------------
include_once('tbs_class.php') ;
$TBS = new clsTinyButStrong ;

//Connexion to the database
require('forum_cnx.php');

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('RssMessage.html') ;

if( !isset($id)){
//echo "<BR>NOT ISSET<br>";
$id=0;
}
$sql = "SELECT * FROM t_forum_message WHERE msg_id = $id";
$TBS->MergeBlock('1st',$cnx_id,$sql);

mysql_close($cnx_id) ;
$TBS->Show() ;
?>

RssMessage.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Forum Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="forum_style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.code {
    border: 1px solid #000066;
    background-color: #F8F8F8;
    font-family: "Courier New", Courier, mono;
    font-size: 11px;
    padding:2pt;
    margin: 2px;
    color: #000066;
}
.url {
    border: 0px solid;
    width: 30px;
    color: #666666;
}
-->
</style>
</head>
<body >

<table width="400" border="1" cellpadding="5" cellspacing="0">
    <tr>
    <td valign="top" bgcolor="#B1CBE4">
    [1st.msg_subject] (from: [1st.msg_email])<hr>[1st.msg_body]</td>
    </tr>
</table>
   
</body>
</html>


HTH,
Tom
By: Skrol29
Date: 2005-11-14
Time: 00:31

Re: RSS Feed from TBS Forum

Hey Tom, this is great !

I've made some few chnages in the forum following your code.
A TBS RSS is now available (in beta) at the link:
  http://www.tinybutstrong.com/rss.php

I'll see if this RSS should better list messages or threads ; it's and if it can be interesting to add more chanels.

Thanks Tom for your code and for this idea :)
By: Tom
Date: 2005-11-14
Time: 14:42

Re: RSS Feed from TBS Forum

Can I pass it a parameter to control the number of posts to retrieve ??

Like
http://www.tinybutstrong.com/rss.php?numshow=7

Thanks

By: Skrol29
Date: 2005-11-15
Time: 00:18

Re: RSS Feed from TBS Forum

Ok, it's now available.

  http://www.tinybutstrong.com/rss.php?nbr=7

max = 50
By: Scythe
Date: 2005-11-16
Time: 23:28

Re: RSS Feed from TBS Forum

Awesome :D

I'll be subscribed shortly.  This is great for the people who are like me developing massively huge sites with this awesome templating system.

BTW, look for a site similar to myspace.com using this templating system ;)
By: Maz
Date: 2005-11-18
Time: 09:49

Re: RSS Feed from TBS Forum

Compliments to the chef. :) Added to my forum RSS Imports.
By: neverpanic
Date: 2005-12-12
Time: 00:02

Re: RSS Feed from TBS Forum

Doesn't work for me (Firefox 1.5) anymore. Why?
By: Skrol29
Date: 2005-12-12
Time: 02:13

Re: RSS Feed from TBS Forum

It still wors fine for me, FireFox 1.5 too.
By: neverpanic
Date: 2005-12-12
Time: 22:46

Re: RSS Feed from TBS Forum

Can you please change the Content-Type header from
Content-Type: text/html
to
Content-Type:text/xml
using
header('Content-Type: text/xml');
I think that's why it doesn't work for me.
By: Skrol29
Date: 2005-12-13
Time: 00:20

Re: RSS Feed from TBS Forum

Ok, I've changed that.

Personal Google can read the TBS RSS, but FireFoxe return an error:
XML Parsing Error: prefix not bound to a namespace
Location: http://www.tinybutstrong.com/rss.php?nbr=7
Line Number: 14, Column: 3
         <content:encoded><![CDATA[ Can you please change the Content-Type header from<br />
---------^
I think it has nothing to do with my change.
If any body can help...
By: Tom
Date: 2005-12-13
Time: 00:25

Re: RSS Feed from TBS Forum

Skrol

I've been running  Firefox (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5) all the time from the very beginning of the RSS feed script(s) and have never gotten any errors.

Not getting the error you identified (above) either.

By: Skrol29
Date: 2005-12-13
Time: 00:32

Re: RSS Feed from TBS Forum

Tom : how strange !!!
Did you tried the given URL
   http://www.tinybutstrong.com/rss.php?nbr=7
?

I.E. returns to me the same kind of message, with a different design :(
By: Tom
Date: 2005-12-13
Time: 00:43

Re: RSS Feed from TBS Forum

Even more strange -- I was using that URL - but reading it into an RSS reader (under PmWiki) when not getting any errors

Going directly to the URL I DO GET the error in Firefox

But I get the following nice XML file in Mozille 1.7.12

<rss version="2.0">
-
    <channel>
<title>TinyButStrong Forum</title>
<description>TinyButStrong Forum in English</description>
<link>http://www.tinybutstrong.com/</link>
-
    <item>
<title>Re: RSS Feed from TBS Forum</title>
<link>http://www.tinybutstrong.com/forum.php?msg_id=4078</link>
-
    <description>
Tom : how strange !!!
<br/>

Did you tried the given URL
<br/>

   http://www.tinybutstrong.com/rss.php?nbr=7
<br/>

...
</description>
-
    <content:encoded>
Tom : how strange !!!<br />
Did you tried the given URL<br />
   http://www.tinybutstrong.com/rss.php?nbr=7<br />
?<br />
<br />
I.E. returns to me the same kind of message, with a different design :(
</content:encoded>
<pubDate>2005-12-13 00:32:39</pubDate>
</item>
-
((( snipped by Tom )))

-
    <item>
<title>Re: Example of class for MySQL DB</title>
<link>http://www.tinybutstrong.com/forum.php?msg_id=4011</link>
-
    <description>
Hello,
<br/>
<br/>

> If TBS has the built in support, then where do I configure
<br/>

> the host, username, passw...
</description>
-
    <content:encoded>
Hello,<br />
<br />
&gt; If TBS has the built in support, then where do I configure<br />
&gt; the host, username, password, and dbname?<br />
<br />
TBS doesn't performe any connection. Not for MySQL and neither for any other data source. You have to open your connexion, then TBS can use it.<br />
<br />
Regarding to your code, you can do the following:&#91;code]<br />
$connect = new dbConnect;<br />
$connect-&gt;dbConnect();<br />
...<br />
$TBS-&gt;MergeBlock('blkname', $connect-&gt;link, 'SELECT * FROM tbl1');<br />
&#91;/code]<br />
<br />
or &#91;code]<br />
$connect = new dbConnect;<br />
$connect-&gt;dbConnect();<br />
...<br />
$TBS-&gt;MergeBlock('blkname', 'mysql', 'SELECT * FROM tbl1');<br />
&#91;/code]<br />
This second issue is possible because Php enables you to use MySql functions without precising the connection Id.<br />

</content:encoded>
<pubDate>2005-11-30 16:08:56</pubDate>
</item>
</channel>
</rss>
By: Tom
Date: 2005-12-13
Time: 00:52

Re: RSS Feed from TBS Forum

Skrol

Ooops: forgot to tell you to look at the "View Source" under Firefox (I won't include it here ;;-)

It looks fine in the page source (same as the Mozilla page did) ... even more strange'r ... over my head...
By: Skrol29
Date: 2005-12-13
Time: 00:58

Re: RSS Feed from TBS Forum

It seems ok now.

I've deleted the Xml Element "<content>" which is not part of the Rss 2.0 specification. It has a suffix <content:encoded> which was making problems for the Xml validation.

I've also changed the items of the RSS, it gives only the last message for a thread.
By: neverpanic
Date: 2005-12-13
Time: 15:30

Re: RSS Feed from TBS Forum

And it finally works for me, too...

Weird that Mozilla behaves different on different systems, because it worked for you before you changed the content-type :(
Maybe a bug?