Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

RssFeedDisplay

Summary: How to add an RSS feed to a page
Version: 1.32 - 2005-10-30
Prerequisites:
Status:
Maintainer:
Categories: RSS

Goal

Adding an RSS feed to your page.

Use the rss feed from another site, or your own, to be displayed on your wiki. For example, include the most recent changes. (That could also be done with a [include:RecentChanges]], but when using a parser you can easily change the look, or display only the top 10 changes.) This is also a good way to display images dynamically from Flickr.

Solution with Magpie

An RSS parser like Magpie will do all the work for you, only thing left is to display it nicely.

Your host must allow outgoing http requests.

How do I check if my host allows outgoing http requests?

Try to include an external url with this markup : IncludeUrl

Is this a setting I need to change in the Apache config file(s)?
Try it? ( I will try to make a test script soon)

Installation:

  • Download the latest magpieRSS version from the Magpie site. You need the following files installed:
    • YOURWIKIHOME/local/magpie/rss_cache.inc
    • YOURWIKIHOME/local/magpie/rss_fetch.inc
    • YOURWIKIHOME/local/magpie/rss_parse.inc
    • YOURWIKIHOME/local/magpie/rss_utils.inc
    • YOURWIKIHOME/local/magpie/extlib/Snoopy.class.inc
THE FILE DOWNLOADED BY CLICKING ON RSSDISPLAY.PHP IS NOT A PHP FILE!!!
I WOULD NOT DOWNLOAD IT IF I WERE YOU
(It is actually a copy of magpie-0.72.tar.gz)

Create a cache-directory to avoid having the rss feed fetched a zillion times a day. Ensure the directory is writable for the webserver (chmod 777)

In the top section of the rssdisplay.php file, there are some settings for the caching. You might want to adjust the location of the cache directory or the expiration time. The expiration time is the (minimum) time between fetching a rss-feed.

 
define('MAGPIE_CACHE_AGE', 2*60*60); #expiration time (seconds).
define('MAGPIE_CACHE_DIR', "$FarmD/cache"); # location this is YOURWIKIHOME/cache

Note: 2*60*60 is two times 60 minutes times 60 seconds, aka 2 hours

add the following lines to your local/config.php (in this order or rssdisplay fails)

include_once("$FarmD/local/magpie/rss_fetch.inc");
include_once("$FarmD/local/rssdisplay.php");

Question: Your instructions just above say to add inclusion of rssdisplay.php "or" rss_fetch.inc to config.php. Should that say "and" - should the admin include both files??
Answer:You have to add both to your config.php. I have changed it

Testing

For testing it might be usefull to put a comment (#) in front of the line in rssdisplay.php:

error_reporting(0);

This line avoids some very ugly error messages when fetch fails.

Usage

  • (:RSS http://example.com/rss.xml [long|short] number_of_items>:)

Defaults

  • how: short
  • number_of_items: 10
Will display the items in a simple list with a max of ten items:
  • (:RSS http://example.com/rss.xml:)

To display a long format and a max of 5 items use:

  • (:RSS http://example.com/rss.xml long 5:)

Example

Guys it didnt work for me. Can anyone tell me step by step guide to add magpie RSS display to pmwiki

     --Amala Singh(amalasingh@gmail.com)

Apache's documentation doesn't say anything on enabling outgoing http requests. Is this something that would be known by a different name? Searching for "outgoing http" on the Apache documentation site yields no relevant information. --Mike Linke

History

2005-10-301.32Added html_entity_decode for the rss-url (tanks to JohnCooley?)
  Added some utf8 translation to html entities
  Cleaned the Comments & Bugs list below a bit
2005-10-181.31Looks like the htmlspecialchars stuff was not a good thing
2005-10-111.30replaced ',' with space as seperator;setting error_reporting to zero;cleaned up html output;added conversion htmlspecialchars
2004-12-13 Pmwiki 2.0 beta
2004-05-161.14Magpie 0.61 basic atom support
2004-01-121.4Using new Keep function
Added <ul> to meet xhtml validation
2004-01-121.2Added more ways to display the feed.
2004-01-101.0Initial version.

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on June 21, 2008, at 12:36 PM