SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2000
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RSS Working but questions

    Hi all,

    I followed a tutorial to setup an RSS Feed and it's all working ok, I wanted to add more than the title and content but haven't been able to work it out and now I'm not even sure if I'm doing the right thing.

    This is my test feed: http://www.phatjoints.com/newsfeeds/rsstestfeed.php

    This is the code:
    Code:
    <?php
    header("Content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
    // Set RSS version.
    echo "
    <rss version=\"2.0\"> ";
    // Start the XML.
    echo "
    <channel>
    <title>News From Around The World</title>
    <description>News and Information from all over the web brought to you by phatjoints.com</description>
    <link>http://www.phatjoints.com/</link>";
    // Create a connection to your database.
    require("config.php");
    // Query database and select the last 10 entries.
    $data = mysql_query("SELECT * FROM rssfeeds ORDER BY NewsID DESC LIMIT 10");
    while($row = mysql_fetch_array($data))
    {
    
    // Continue with the 10 items to be included in the <item> section of the XML.
    echo "
    <item>
    <link>http://www.phatjoints.com/newsfeeds/details.php?id=".$row[NewsID]."</link>
    <guid isPermaLink=\"true\">http://www.phatjoints.com/newsfeeds/details.php?id=".$row[NewsID]."</guid>
    <title>".$row[Title]."</title>
    <description><![CDATA[".$row[Content]."]]></description>
    </item>";
    }
    echo "
    </channel>
    </rss>";
    ?>
    What I was thinking was to add the source of the news as a link. I have the field 'Source' in my database and that contains the links to the original stories.

    Now I'm not sure if this additional info should go into the feed or whether it should be on a new page. One that's formatted using XHTML/CSS etc?

    Should the feed only show the Title and Content as it currently is?

    Thanks in advance

  2. #2
    SitePoint Evangelist
    Join Date
    May 2006
    Location
    Denmark
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The <source> tag is supposed to be like this: <source url="http://www.sitepoint.com">SitePoint</source>

    Note, however, that, seeing as it's just an XML document, the user agent is free to generate the layout for the feed itself (including not showing the source).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •