A jQuery and PHP RSS Feed Syndicator (with auto-reload!)

A jQuery and PHP RSS Feed Syndicator (with auto-reload!)

This simple jQuery and PHP feed loader is a dead simple and effective way of adding the contents of a news feed to any page you choose. Inserted into a page using only jQuery, it’ll allow you to keep your users up to date with whatever’s happening right now with it’s inline Ajax powered reload.

There are several ways in which you can display the contents of an RSS feed within another page: doing it only with built-in PHP functions on page-load; using external classes or by using JavaScript itself to grab and parse a feed using a PHP proxy. All of which have their distinct advantages and disadvantages.

The method I’m using is a combination of the two, using PHP to grab and parse the feed and then JavaScript (via jQuery) to load the data into the page and auto-update it every 10 seconds (or by whatever period you’d wish). The PHP is based on Gary White’s very effective RSSReader.

Usage

The address of the feed to be displayed is determined in rssfeed.php (contained within archive provided below), you can edit it as you see fit. Once this edit has taken place the demo should function perfectly, displaying the most recent entry from the specified feed.

However, if you wish to install the feed syndicator on another page (and let’s face it, you probably will) it’s simply a matter of copying the JavaScript marked and contained with the header of index.html (included in the download) into the desired page and adding id=”rssUpdater” to the div where you’d like the feed to be displayed.

Note: When installing the script, be aware that you need to keep rssfeed.php and rssreader.php within the same directory, and that the path to rssfeed.php needs to be accurately determined in the JavaScript.

If you’s like to alter the length of time between auto updating the data, it can be set up changing the value used by the JavaScript: this is set to 10000 milliseconds in the demo (10 seconds, obviously( but can be pretty much anything you like.

At following links you’ll find the demo and a link to download the zip file.

As always, if you have any questions feel free to ask in the comments.

3 comments on A jQuery and PHP RSS Feed Syndicator (with auto-reload!)

  1. habibur says:

    great, this PHP5?

  2. Murat says:

    it shows only 1 news from xml, how can i show all news with queue ?

  3. DOtnet says:

    tnx for the information , i have a question where i find the rss pages becouse i need a rss of programmers?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>