RSS - After the template

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

RSS - After the template

Post 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!

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

no, unless you map xml to be parsed by php (in which case you really really should turn off short_tags)
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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.
Post Reply