Page 1 of 1

RSS - After the template

Posted: Wed Sep 07, 2005 9:17 am
by $var
Here is my working template.
When this page is posted on the server, and linked to through an RSS reader (I use Thunderbird)
It shows up within the group as it's own feed, RSS FEED NAME, with one item in the list: TOPIC TITLE
So, that's a good start...

Code: Select all

<?xml version="1.0" encoding="windows-1252"?>
<rss version="2.0">
  <channel>
    <title>RSS FEED NAME</title>
    <description>This is a description for the RSS reader to display</description>
    <link>http://www.20hzmusic.com/toronto/rss/rss.html</link>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <lastBuildDate>Sat, 18 Jun 2005 18:19:33 -0400</lastBuildDate>
    <pubDate>Sat, 18 Jun 2005 18:19:17 -0400</pubDate>
    <generator>FeedForAll v1.0 (1.0.2.0) unlicensed version</generator>
    <item>
      <title>TOPIC TITLE</title>
      <description>This is the actual feed where the news is displayed.</description>
      <link>http://www.20hzmusic.com/toronto/rss/rss.html</link>
      <pubDate>Sat, 18 Jun 2005 18:19:16 -0400</pubDate>
    </item>
  </channel>
</rss>

What would be super cool, would be a way to use PHP's <? echo $result("Title"); ?> or some XML equivalent that would allow this template to grab threads from my database, and create multilpe items.

Is this the norm for creating feeds? I have read a bunch of verbose codes that have a lot going on. This is the most concise, http://timvw.madoka.be/programming/php/rss.txt, and even it has 4 includes.

If anyone has had this thought, and been able to merge the two, could you please fill me in on the union? Thanks a lot!


Posted: Wed Sep 07, 2005 10:54 am
by feyd
basically, you set up the file such that it sends the correct header() for the content-type. Next, you'll likely have to echo out the xml start up tag (short tags on). After that, it's like any other script, as far as I know.

Posted: Wed Sep 07, 2005 3:08 pm
by $var
so... XML and PHP will work together? If i name the file, say.... rss.xml, the PHP tags will be parsed as they should be?

Posted: Wed Sep 07, 2005 3:19 pm
by feyd
no, unless you map xml to be parsed by php (in which case you really really should turn off short_tags)

Posted: Wed Sep 07, 2005 4:15 pm
by $var
for those who don't understand what this means (as i don't know what short tags are) i found this document that may help explain what you need to be doing.

http://ca.php.net/xml

Posted: Wed Sep 07, 2005 5:15 pm
by patrikG
I've been using Manuel Lemos's RSS writer class ( http://www.phpclasses.org/browse/package/560.html ). Doesn't support RSS 2.0, but it does the job and pronto.