Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Creating a RSS feed

Options
  • 08-11-2005 12:37am
    #1
    Closed Accounts Posts: 7,221 ✭✭✭


    Hi

    New to this RSS lark. Is there an application for creating the content on my site? I want to create a news feed for a relatively small group of people (so getting listed on an aggregator is not a requirement). Any pointers for a newbie?


Comments

  • Subscribers Posts: 9,716 ✭✭✭CuLT


    BrianD wrote:
    Hi

    New to this RSS lark. Is there an application for creating the content on my site? I want to create a news feed for a relatively small group of people (so getting listed on an aggregator is not a requirement). Any pointers for a newbie?
    http://www.w3schools.com/rss/default.asp

    It's fairly easy to make one if you store your news in a database; just retrieve info in the correct format (which you can pretty much do by taking an exisitng RSS feed and replacing the code with database queries for your stuff since they're all very similar).

    Though there is proper RSS text formatting which I've neglected to pay attention to so far. Too complicated to learn at a glance so I left it :)


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    Judging from your signature I'd imagine you want an RSS feed for the news articles?

    If so this should help, if not you can edit it around to your own likings (btw this will only work if you're using php/mysql):
    [php]<?php
    header ("Content-type: text/xml"); // Output file as XML

    echo ("<?xml version=\"1.0\" encoding=\"US-ASCII\"?>\n") // The XML declaration

    ?>
    <rss version="0.91">

    <channel>
    <title>{TITLE OF YOUR NEWS FEED}</title>
    <link>{LINK TO YOUR SITE}</link>
    <description>RSS Feed for {YOUR SITE}</description>
    <language>en-us</language>
    <copyright>Copyright 2005 {YOUR NAME}</copyright>
    <webMaster>{YOUR EMAIL ADDRESS}</webMaster>

    <?
    $dbhost = 'localhost';
    $dbuser = '{YOUR DATABASE USER NAME}';
    $dbpasswd = '{YOUR DATABASE PASSWORD}';
    $dbname = '{YOUR DATABASE NAME}';

    mysql_connect($dbhost,$dbuser,$dbpasswd)
    or die ("Cannot connect to database server.");

    mysql_select_db($dbname)
    or die ("Cannot connect to database.");

    // this is an example of a way of pulling data from a phpBB database to make a feed, if you could post up the way you store your data I can give you the query you'll need to use

    $news = mysql_query ("SELECT DISTINCT t.topic_title, t.topic_last_post_id, p.post_time, p.poster_id, f.forum_name, f.forum_id, u.user_id, u.username, m.post_id, m.post_text
    FROM phpbb_topics AS t, phpbb_posts AS p, phpbb_forums AS f, phpbb_users AS u, phpbb_posts_text AS m
    WHERE
    t.forum_id = f.forum_id
    AND p.topic_id = t.topic_id
    AND p.post_id = t.topic_last_post_id
    AND p.poster_id = u.user_id
    AND p.post_id = m.post_id
    ORDER BY p.post_time DESC LIMIT 20")
    or die (mysql_error());

    while ($newsrow = mysql_fetch_array ($news))
    //loops through results of SELECT displaying each items data
    {
    $fname = $newsrow;
    $fid = $newsrow;
    $tname = $newsrow;
    $tid = $newsrow;
    $uname = $newsrow;
    $uid = $newsrow;
    $text = ShortenText($newsrow);

    echo "<item>\n";
    echo "<title>$fname - $tname</title>";
    echo "<link>\n {URL TO YOUR WEBPAGE WHERE THE ARTICLES ARE PARSED}.php?p=$tid#$tid \n</link>";
    echo "<description>\n $text \n</description>";
    echo "</item>";
    }

    unset($news,$row); //destroys variables so the var names can be reused
    ?>
    </channel>
    </rss>
    [/php]
    Change all the parts with {} around them to your needs...

    Edit: Just realised all the pages are html... hmm, you'd need to manually edit the RSS file each time you post something


  • Registered Users Posts: 9,196 ✭✭✭MrVestek


    Couldn't he just rename the pages .php and impliment this code using php? It wouldn't be any major reworking of the site.


  • Registered Users Posts: 1,418 ✭✭✭Steveire


    You might be able to give more info on what you want to do with the feed.

    Here's an option:

    1. Install wordpress on the site.

    2. Take the feed from that, and put it on the site where you want to put the news.

    3. Make entries to the blog, which will then appear in the feed.

    As an alternative to step one, set up a free blog at one of millions of blog sites. To implement step two, go here and put the URL of the feed in the box provided (it might be phantomfm.blogs.ie/feed if you use blogs.ie), and it'll make the code for you at the bottom of the page. You then just copy that code to the source code of the page on phantomfm.com where you want the feed to appear.

    I'm not even sure if this is what you want to do, but you can see what i mean if you look at the announcements box on this page(work in progress).


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    Achilles wrote:
    Couldn't he just rename the pages .php and impliment this code using php? It wouldn't be any major reworking of the site.
    The posts would have to be held in a database he could pull data from, if the files were just renamed *.php the articles would still just be hardcoded into the HTML of the site.


  • Advertisement
  • Registered Users Posts: 9,196 ✭✭✭MrVestek


    steveland? wrote:
    The posts would have to be held in a database he could pull data from, if the files were just renamed *.php the articles would still just be hardcoded into the HTML of the site.
    That's not what I meant. What I meant was, he could rename the page .php and have the existing HTML, then the portion of the HTML that pulls info from the database can be rewritten in php as they work better together, ie:

    <?php

    statements

    >


Advertisement