Create a new article
Write your page title here:
We currently have 3,185 articles on s23. Type your article name above or click on one of the titles below and start writing!



Integrate RSS newsfeeds into wiki pages using magpie RSS parser in a custom Mediawiki extension:

(For example to interwiki syndicate RecentChanges pages like on the recent near changes.)

mutante 21:35, 25 Mar 2005 (CET)







del.icio.us UTF-8 test[edit]


FFII News feed test[edit]


Linux ml[edit]



# RSS-Feed Mediawiki extension
# using magpieRSS (http://magpierss.sourceforge.net/)
# by mutante 25.03.2005

# requiring magpie (see above)

# give it a name
$wgExtensionFunctions[] = "wfRssExtension";

# register with global parser (http://meta.wikimedia.org/wiki/Write_your_own_MediaWiki_extension)
function wfRssExtension() {
global $wgParser;

# set hook (trigger) to rss, means <rss> will be made active tag
$wgParser->setHook( "rss", "renderRss" );

# the actual function (taking input)
function renderRss( $input ) {

# maybe its a good idea to escape string user input so they dont try to attach nasty things
# $input = mysql_escape_string($input);

# fetch the feed (magpie's job)
$rss = fetch_rss($input);

# setting variables for table head

# putting the html table head into the output variable

$output="<table><tr><th align='left' colspan='3'><i>RSS-feed included from:</th></tr>
<th colspan='2'><a href='$link'>$title</a></th>

# now a loop to add table rows until none more are found

foreach ($rss->items as $item) {

# setting variables for table row

$href = $item['link'];
$title = $item['title'];
$date = $rss->dc['date'];
$description = $item['description'];

# adding each single row (still in loop) (.= appends = would overwrite)

$output.="<tr><td>date $date</td><td colspan='1'><a href='$href'>$title</a></td><td>$description</td></tr>";

# loop done ,adding final tag to close table properly

# dump the output all at once
return $output;



Extended version by Duesentrieb[edit]

This is an extended version of the RSS-feed extension by mutante (http://meta.wikimedia.org/wiki/User:mutante/RSSFeed). It's main features are charset conversion, nicer formating and output of the full description text of the news items. It also introduces a syntax for controlling those features.

# RSS-Feed Mediawiki extension
# original by mutante 25.03.2005
# extended by Duesentrieb 30.04.2005
# Requires: 
#  * magpie rss parser <http://magpierss.sourceforge.net/>
#  * iconv <http://www.gnu.org/software/libiconv/>, see also <http://www.php.net/iconv>
# Installation:
#  * put this file (rss.php) into the extension directory of your mediawiki installation 
#  * add the following to the end of LocalSettings.php: include("extensions/rss.php");
#  * make sure magpie can be found by PHP.
# Usage:
#  Use one section between <rss>-tags for each feed. The ress section may contain parameters
#  separated by a pipe ("|"), just like links and templates. Two parameters are supported:
#    * charset=...   the charset used by the feed. iconv is used to convert this.
#    * short         do not show the description text for each news item.
# Example: 
#    <rss>http://slashdot.org/slashdot.rss|charset=UTF-8|short</rss>

#change this according to your magpie installation!

#install extension hook
$wgExtensionFunctions[] = "wfRssExtension"; 

#extension hook callback function
function wfRssExtension() { 
   global $wgParser;
   #install parser hook for <rss> tags
   $wgParser->setHook( "rss", "renderRss" );
#parser hook callback function
function renderRss( $input ) {
   global $wgOutputEncoding;

   # $input = mysql_escape_string($input);
   if (!$input) return ""; #if <rss>-section is empty, return nothing
   #parse fields in rss-section
   $fields= explode("|",$input);
   $url= @$fields[0];
   $args= array();
   for ($i=1; $i<sizeof($fields); $i++) {
       $f= $fields[$i];
       if (strpos($f,"=")===False) $args[strtolower(trim($f))]= True;
       else {
               list($k,$v)= explode("=",$f,2);
               $args[strtolower(trim($k))]= trim($v);

   #get charset from argument-array    
   $charset= @$args["charset"];
   if (!$charset) $charset= $wgOutputEncoding;
   #get short-flag from argument-array
   #if short is set, no description text is printed
   $short= @$args["short"];
   #fetch rss. may be cached locally.
   #Refer to the documentation of magpie for details.
   $rss = @fetch_rss($url);
   #check for errors.
   if ($rss->ERROR) {
       return "<div>Failed to load RSS feed from $url: ".$rss->ERROR."</div>"; #localize...
   if (!is_array($rss->items)) {
       return "<div>Failed to load RSS feed from $url!</div>"; #localize...

   #Bild title line    
   $title= iconv($charset,$wgOutputEncoding,$rss->channel['title']);
   if ($rss->channel['link']) $title= "<a href='".$rss->channel['link']."'>$title</a>";
   #Bild items
   if ($short) { #short item list
       foreach ($rss->items as $item) {
               $href = trim(iconv($charset,$wgOutputEncoding,$item['link']));
               $title = trim(iconv($charset,$wgOutputEncoding,$item['title']));
               $output.="<li><a href='$href'>$title</a></li>";
   else { #full item list
       foreach ($rss->items as $item) {
               $href = trim(iconv($charset,$wgOutputEncoding,$item['link']));
               $title = trim(iconv($charset,$wgOutputEncoding,$item['title']));
               #bild description text if desired
               if ($item["description"]) {
                       $text= trim(iconv($charset,$wgOutputEncoding,$item['description']));
                       #avoid pre-tags
                       $text= str_replace("\r"," ",$text);
                       $text= str_replace("\n"," ",$text);
                       $text= str_replace("\t"," ",$text);
               else $text = "";
               $output.="<dt><a href='$href'>$title</a></dt>";
               if ($text) $output.="<dd>$text</dd>\n";
   return $output;


from: http://meta.wikimedia.org/wiki/User:Duesentrieb/RSS

also this version has been extended. See http://meta.wikimedia.org/wiki/User:Alxndr/RSS !

Cookies help us deliver our services. By using our services, you agree to our use of cookies.