FF1+ IE5+ Opr8+

Pausing RSS scroller

Author: Dynamic Drive

Description: Pausing RSS scroller is an innovative scroller that combines PHP and external JavaScript to let you show any RSS feed on your site- and beyond! By bypassing Ajax in favour of dynamically loaded JavaScript, the scroller can be included on any site, enabling you to syndicate your feed for other sites to display, just by allowing webmasters to cut and paste the frontend portion of this script. This differs from RSS Ticker script, which uses Ajax and PHP instead, making it suitable only for displaying on your own site (as Ajax by default limits the domain it can be invoked from out of security reasons).

This script works by first relying on a simple PHP RSS parser called LastRSS to retrieve/cache an RSS feed. Then, it converts the result to a JavaScript array and loads it up dynamically and asynchronously (without interrupting the rest of the page) through an external JavaScript file. External JavaScript can be invoked on any site, enabling this script to be used just the same. And just because we're so thoughtful, the script does support the ability to limit its usage to specified domains of your choice.

Requirement of this script: Support for PHP for the site hosting the LastRSS script.

Here are some features of Pausing RSS scroller:

  • Displays any RSS feed on the web in a scroll and pause fashion. Specify exactly what components of the feed items to display, such as the title of the item, description, or post date.
  • Each RSS feed is cached on the server for best performance. LastRSS feature.
  • Complete customization of each RSS ticker instance through the frontend JavaScript- specify which RSS feed to show, the CSS id and classname to be applied to it for styling, and what parts of the feed to show (ie: title+description).
  • RSS feed is fetched asynchronously similar to in Ajax, so its loading process does not affect that of the rest of the page.
  • Scroller pauses onMouseover.
  • Display multiple RSS tickers on a page, each with their own independent settings.
  • Scroller can be embedded on any site, allowing for syndication of a feed on other sites.
  • Ability to limit the domains that are allowed to show the RSS scroller through referral checking, if you do not wish any site to show it (anti-syndication).

Demos:

Each scroller instance is called independently on the page, using the core function:

<script type="text/javascript">
//new rsspausescroller(RSS_id, divId, divClass, delay, linktarget, optionalswitch)
new rsspausescroller("cnn", "pscroller1", "rssclass", 3000, "_new", "description+date")
</script>

Detailed info below.


Directions: The easiest way to install Pausing RSS scroller is to download the zip file below:

-rsspausescroller.zip

which contains all the files that make up the script. They are:

  • demo.htm: working demo of Pausing RSS Scroller
  • rsspausescroller.js: Pausing scroller JavaScript engine.
  • lastrss/scrollerbridge.php: PHP script that converts requested RSS feed from lastRSS into JavaScript array
  • lastrss/lastRSS.php: lastRSS.php class, unmodified.

Follow the below instructions step by step to install the scroller on your page:

1) For demo.htm:

Open up "demo.htm", and copy the code found inside into the page(s) you wish the ticker to be displayed in. Make sure the code:

<script type="text/javascript" src="rsspausescroller.js">
//credit notice here
</script>

inside the HEAD section correctly references the location of "rsspausescroller.js" on your server, if it's been moved to a different directory.

The code inside the BODY section shows how to invoke an RSS scroller instance:

<script type="text/javascript">
//new rsspausescroller(RSS_id, divId, divClass, delay, linktarget, optionalswitch)
//1) RSS_id: "Array key of RSS feed in scrollerbridge.php script"
//2) divId: "ID of DIV to display ticker in. DIV is dynamically created"
//3) divClass: "Class name of this ticker, for styling purposes"
//4) delay: delay between message change, in milliseconds
//5) linktarget: Target of links inside RSS feed. Set to "" for current page.
//6) optionalswitch: "optional arbitrary" string to create additional logic for formatrssmessage() to use.
// By default, optionalswitch supports "date", or "date+description" to also show these parts of a RSS feed.

new rsspausescroller("dynamicdrive", "pscroller2", "rssclass", 3000, "", "date+description")

</script>

2) For rsspausescroller.js:

Open up "rsspausescroller.js", and at the top, simply make sure the URL to "scrollerbridge.php" on your server is correct:

//URL to "scrollerbridge.php" on your server:
var bridgepath="lastrss/scrollerbridge.php"

3) For scrollerbridge.php:

Scrollerbridge.php is our custom PHP script that returns the RSS feed from lastRSS.php as a JavaScript array. Open up this file using any text editor, and edit the variables as instructed by the comments. Some variables belong to that of LastRSS, and it is recommended you read up on the documentation for lastRSS to get a full understanding of what these variables mean and how you can take advantage of all of the available features.

Two variables of interest are:

$rss->cache_time = 1800; //Global cache time before fetching RSS feed again, in seconds.

$allowedDomains=""; //Domains that are authorized to display scroller.

The first one sets the caching period of every RSS feed on your server, in seconds. A good value is at least 1/2 hour (1800). Note that while you're testing out the script privately on your server, you may wish to set it to "0" temporarily, so any changes you make are instantly acknowledged.

The second variable lets you define a list of domains that are authorized to show the scroller. By default, it's set to a blank string (""), meaning any site can just copy the front end JavaScript code and display the feed (great for syndication). If you wish to limit it so only your own sites can run the scroller, just define the allowed domains using this variable, each separated by a comma:

$allowedDomains="dynamicdrive.com, javascriptkit.com, whatever.com";

4) For lastRSS.php: No editing required. Upload as is.

And that's it!

Syndicating your RSS feed on other sites using Pausing RSS scroller

As mentioned, one of the defining characteristics of Pausing RSS scroller is its ability to be called from any site, enabling you to offer other sites a way to syndicate/ display your RSS feed on theirs. To do so, simply offer them the frontend JavaScript of Pausing RSS scroller to cut and paste onto their sites, namely, the code inside demo.htm. Make sure that:

A) The reference to rsspausescroller.js (inside the script of step 1) is absolute and correct:

<script type="text/javascript" src="http://www.mysite.com/rsspausescroller.js">
//credit notice here 
</script>

B) On your own server, that the reference to "scrollerbridge.php" inside rsspausescroller.js is absolute and correct:

var bridgepath="http://www.mysite.com/lastrss/scrollerbridge.php"

C) And finally, on your own server, that the $allowedDomains variable inside "scrollerbridge.php" is set to a blank string:

$allowedDomains="";

Time to display some nice RSS feeds on your site, and spread that love as well!

Wordpress Users: Step by Step instructions to add ANY Dynamic Drive script to an entire Wordpress theme or individual Post