Extension talk:SimpleFeed

From mediawiki.org

Setting char limits[edit]

Hi, I've modified the extension in order to set a limit of chars displayed in the description field.

* SimpleFeed MediaWiki extension
* Copyright (C) 2007-2008 Jonny Lamb <jonnylamb@jonnylamb.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or 
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
* Last modified: Isaac Contreras - fladei
* 		4 October 2011
* Added:	Line 96 to get the limit of maximum chars
* 		Line 126 to cut the Description string to accomplish the limit of maximum chars

// Check to make sure we're actually in MediaWiki.
if (!defined('MEDIAWIKI'))
	echo 'This file is part of MediaWiki. It is not a valid entry point.';

// Path to simplepie.inc (including leading slash).
$simplepie_path = './extensions/SimpleFeed/';

// Path to SimplePie cache folder (excluding leader slash).
// Defaults to "./extensions/cache"
$simplepie_cache_folder = $simplepie_path . 'cache/';

if ( ! @include($simplepie_path.'simplepie.inc') )
	define('SIMPLEPIE_NOT_FOUND', true);

$wgExtensionFunctions[] = 'wfSimpleFeed';
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'SimpleFeed',
	'description' => 'Uses SimplePie to output RSS/atom feeds',
	'author' => 'Jonny Lamb',
	'url' => 'http://www.mediawiki.org/wiki/Extension:SimpleFeed'

function wfSimpleFeed()
	global $wgParser;
	$wgParser->setHook('feed', 'parseFeed');

//function parseFeed($input, $args, &$parser)
function parseFeed($input, $args, $parser)
	global $simplepie_cache_folder;

	// Disable page caching.
	// Check to see whether SimplePie was actually included.
	if (defined('SIMPLEPIE_NOT_FOUND'))
		return '<strong>Error</strong>: <code>simplepie.inc</code> was not found in the path. Please edit the path (beginning of extensions/SimpleFeed.php) or add <code>simplefeed.inc</code> to the current path.';
	// Must have a feed URL and a template to go by outputting items.
	if (!isset($args['url']) or !isset($input))
		return 0;

	$feed = new SimplePie();


	// Get the feed information!


	// Either use default date format (j F Y), or the $date(string) argument.
	// The date argument should conform to PHP's date function, nicely documented
	// at http://php.net/date.
	$date = (isset($args['date'])) ? $args['date'] : 'j F Y';
	$limit = (isset($args['limit'])) ? $args['limit'] : '100';
	$output = '';

	// Use the $entries(int) argument to determine how many entries to show.
	// Defaults to 5, and 0 is unlimited.
	if (isset($args['entries']))
		$max = ($args['entries'] == 0) ? $feed->get_item_quantity() : $feed->get_item_quantity($args['entries']);
		$max = $feed->get_item_quantity(5);
	// Loop through each item.
	for ($i = 0; $i < $max; $i++)
		$item = $feed->get_item($i);

		$itemwikitext = $input;

		// {PERMALINK} -> Link to the URL of the post.
		$itemwikitext = str_replace('{PERMALINK}', $item->get_permalink(), $itemwikitext);
		//echo "Link: ".$itemwikitext;
		// {DATE} -> The posting date of the post, formatted in the aforementioned way.
		$itemwikitext = str_replace('{DATE}', $item->get_date($date), $itemwikitext);

		// {DESCRIPTION} -> The actual post (or post description if there's a tear).
		$itemwikitext = str_replace('{DESCRIPTION}', substr($item->get_description(), 0, $limit).'...', $itemwikitext);
		// If $type="planet" is used, the author is got from the post title.
		// e.g. title = "Joe Bloggs: I love Mediawiki"
		// This will make: {AUTHOR} -> "Joe Bloggs"
		//                 {TITLE} -> "I love Mediawiki"
		// If this is not set however, the title and author are received the usual way.
		if ($args['type'] == 'planet')
			$title = preg_replace('/(.*): (.*)/sU', '\\2', $item->get_title());
			preg_match('/(.+?): (.+)/sU', $item->get_title(), $matches);
			$author = $matches[1];
			$title = $item->get_title();
			// Often the author is hard to recieve. Maybe it's not a very important
			// thing to output into RSS...?
			$itemauthor = $item->get_author();
			$author = ($itemauthor != null) ? $itemauthor->get_name() : '';
		// {TITLE} -> Title of the post.
		$itemwikitext = str_replace('{TITLE}', $title, $itemwikitext);
		// {AUTHOR} -> Author of the post.
		$itemwikitext = str_replace('{AUTHOR}', $author, $itemwikitext);

		// Add to the overall output the post just done.
		$output .= $itemwikitext;

	// Parse the text into HTML between the <feed>[...]</feed> tags, with arguments replaced.
	$parserObject = $parser->parse($output, $parser->mTitle, $parser->mOptions, false, false);
	// Output formatted text.
	return $parserObject->getText();


The new param is limit, and you should be able to use it by entering

<feed url="http://myfeed.com" entries=3 type="planet" limit=150>

Use at Wikigender(New Home) --Fladei 18:00, 06 October 2011 (UTC)Reply[reply]

Extension does not work with feeds generated by php-scripts[edit]

Hi, I have a problem it seems your extension does not work with feeds generated by php-scripts.
It does not show anything, only a blank page.
The URL of my RSS feed: http://galdom.portal-werner.de/e107_plugins/rss_menu/rss.php?1.2

Ditto. When I paste your BBC example into my page, I just get the same thing as the output. MatthewBurton 20:56, 7 April 2007 (UTC)Reply[reply]
This extension really does not work for me. Just crashes the page on which I try to include the <feed> tags. -- 23:40, 29 June 2007 (UTC)Reply[reply]
This is a big problem since there are many php generated feeds. Could this be fixed? — Preceding unsigned comment added by (talkcontribs) 20:20, 23 July 2007
Try changing $feed->feed_url($args['url']); to $feed->set_feed_url($args['url']); — Preceding unsigned comment added by (talkcontribs) 16:15, 8 October 2007

How to install[edit]

I couldn't make it work using the provided instructions either. This worked for me

  1. Save SimpleFeed.php to /extensions
  2. Save simplepie.inc to /extensions
  3. Create /extensions/cache. Set correct write permission (chmod). Webserver-user should be allowed to write.
  4. Add include("./extensions/SimpleFeed.php"); to LocalSettings.php. Last line works fine.
 Note: If you are in a corporate environment, check out any proxy servers or firewalls

SimplePie have their own extension for MediaWiki. I installed that first and the instructions are really good. However, you are not able to modify the layout as much as with SimpleFeed. — Preceding unsigned comment added by (talkcontribs) 13:38, 16 April 2007 (UTC)Reply[reply]

Got errors when using


replace it with:


helped. --sandb 15 Oct 2009

Right, same here, use "include" doesn't work. "require_once" does.

MediaWiki 1.10 Support[edit]

Anyone get this to work in MediaWiki 1.10? — Preceding unsigned comment added by (talkcontribs) 16:10, 29 June 2007

Not Yet

I get

Fatal error: Call to undefined method SimplePie::feed_url() in /<my directory>/SimpleFeed.php on line 71

The other SimplePie extension does not work either.

Any help would be appreciated.

Mguentz 01:58, 13 August 2007 (UTC)Reply[reply]

See Extension:SimpleFeed#SimplePie_version_problem--Arcy 18:39, 7 November 2007 (UTC) That worked for me.Reply[reply]

Cache Directory[edit]

When installing, I had to put the cache directory in the root wiki folder, rather than extensions/. Anything else gave me an error. Seems that SimplePie looks there. Cheezerman 19:08, 11 December 2007 (UTC)Reply[reply]

No error for me, but also nothing in the cache folder. (Le Pubard)
I had to change something in simplepie.inc :
before : var $cache_location = './cache';
after : var $cache_location = 'extensions/cache';
— Preceding unsigned comment added by (talkcontribs) 13:18, 6 January 2008


I'm trying to use SimpleFeed with simplepie 1.1.1, php 5.1.1, and mediawiki 1.11

Whenever I load a page with <feed> it returns

Warning: gzinflate() [function.gzinflate]: data error in W:\www\wi\extensions\simplepie.inc on line 7743

Anyone had this issue before? — Preceding unsigned comment added by (talkcontribs) 03:13, 30 March 2008

Howto use SimplePie Addons[edit]


I tried to use one of the SimplePie Addons (i.e. http://simplepie.org/wiki/addons/yahoo_weather)

By adding

$itemwikitext = str_replace('{WEATHER_CONDITION}', $weather->get_condition(), $itemwikitext);

I just get the error

Fatal error: Call to a member function get_condition() on a non-object in /is/htdocs/wp1064305_TTQI81XDD8/www/wiki/extensions/SimpleFeed.php on line 114

But isn't that definied in simplepie_yahoo_weather.inc? I'm using the file from Ryan [1] — Preceding unsigned comment added by Crazyelk (talkcontribs) 19:22, 7 April 2008

Get rid of PHP Notice errors[edit]

To get rid of PHP Notice errors ...

PHP Notice:  Undefined index:  type in /var/www/wiki/wk/extensions/SimpleFeed.php on line 117

... replace ...

if ($args['type'] == 'planet')

... in line 117 with ...

if (isset($args['type']) && $args['type'] == 'planet')

Ivan Pepelnjak 14:03, 6 May 2008 (UTC)Reply[reply]

Hello Jonny Lamb. I was not able to find any resource to contact you. Please include the patch from Ivan above.
Thank you --Mark Ziegler 08:28, 29 November 2010 (UTC)Reply[reply]

In reverse order[edit]

aug 28: I think there's a bug when displaying multiple feed-tags on one page. I made a page with feeds from various sources on a clean install and the Wiki is grinding to a halt after a few refreshes.


This extension almost works fine but as for my Hungarian wiki, it publicate the feeds in reverse order. The latest news are below... :( What should I do? Thanks! 00:49, 22 August 2008 (UTC) (NetBandita)Reply[reply]

after some minutes....
Hmmm.... I have solved. :D In the simplepie.inc there is in the line of 515 the next 'var': var $order_by_date = false; You should change it from true to false. That's all. :)
(sorry for my grammar mistakes if...) 00:56, 22 August 2008

https feeds[edit]

I had trouble using this extension with https-feeds. Turns out that the extension sends "ssl://$host" as the hostname in the Host header.

My ugly fix:

$ diff -u simplepie.inc simplepie.fixed.ssl.inc 
--- simplepie.inc	2008-11-17 16:20:04.000000000 +0100
+++ simplepie.fixed.ssl.inc	2008-11-17 16:20:41.000000000 +0100
@@ -7727,7 +7727,15 @@
 						$get = '/';
 					$out = "GET $get HTTP/1.0\r\n";
-					$out .= "Host: $url_parts[host]\r\n";
+					if (preg_match("/^ssl:\/\//", $url_parts[host]))
+					{
+					  $foo = preg_replace("/^ssl:\/\//", "", $url_parts[host]);
+					  $out .= "Host: $foo\r\n";
+					}
+					else
+					{
+					  $out .= "Host: $url_parts[host]\r\n";
+					}
					$out .= "User-Agent: $useragent\r\n";
					if (extension_loaded('zlib'))

17 November 2008 — Preceding unsigned comment added by (talkcontribs)

Firefox CSS issues in Mediawiki 1.14[edit]

Is anyone else having issues with this extension and importing common.css, etc for Mediawiki 1.14? With my install it seems to be overriding things that should be content type of type/css and forcing type/html which ends up breaking the css import. Anyone else see this and know how to fix it? 16 April 2009 — Preceding unsigned comment added by (talkcontribs)

Outputting HTML tags[edit]

I'm noticing that URLs within the {DESCRIPTION} area are being transcluded in full markup: e.g. <a href="mylink">link text</a> Can this be fixed in any way? Coldmachine 20:39, 20 May 2009 (UTC)
I have the same problem. Any solution or advice,please? --Biris 10:53, 29 June 2009 (UTC)Reply[reply]

It can be fixed, or at least worked around. I added this line in SimpleFeed.php after $feed->set_feed_url($args['url']);

$feed->strip_htmltags(array_merge($feed->strip_htmltags, array('a', 'img')));

I'm sure someone else can make use of the tags instead of wiping them, but that's the best I can do. RotsiserMho 03:45, 29 January 2010 (UTC)Reply[reply]

cURL error 6: Couldn't resolve host 'http:'[edit]

If I attempt to paste:

<feed url="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml">
'''{DATE}, by {AUTHOR}'''

I get the error: "cURL error 6: Couldn't resolve host 'http:'"

<feed>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml</feed> works though.

I have mediawiki 1.7.1. I installed simplepie and simplefeed in March 2008.

i would like to cusomize my feeds, how would I fix this error? Odessaukrain2 16:48, 1 July 2009 (UTC)Reply[reply]

Maybe try to update your MW. There's a new Simplepie version too, 1.2 released in July. But if other feeds work fine maybe its a defect in the feed you're trying to use. --Kenny5 03:37, 31 July 2009 (UTC)Reply[reply]

PHP 5.3 problems[edit]

This extension does not work on my PHP 5.3 system. Error message:

PHP Warning:  Parameter 3 to parseFeed() expected to be a reference, value given in /srv/www/htdocs/wiki/includes/parser/Parser.php on line 3243

I had to change the following line

function parseFeed($input, $args, &$parser)


function parseFeed($input, $args, $parser)

BTW: This error seems to be quite common for PHP applications after upgrade to PHP 5.3.

Display the feed sorted by ascending date[edit]

To display the feed sorted by ascending date, replace ...

// Loop through each item.
for ($i = 0; $i < $max; $i++)

(approximately line 104) with ...

$fOffset = 0; $fMult = 1;
if (isset($args['sort']) and $args['sort'] == 'asc') {
        $fOffset = $max - 1; $fMult = -1;

// Loop through each item.
for ($i = 0; $i < $max; $i++)
        $item = $feed->get_item($i * $fMult + $fOffset);

After the change, the feed is sorted in descending (default) order unless you add the sort="asc" attribute in the feed tag.

Ivan Pepelnjak 09:25, 15 April 2010 (UTC)Reply[reply]

Simple use - didn't work[edit]

The 'Simple use'-method didn't work (showed a zero (0)) SimpleFeed requires a url-argument and a 'template' ($input)

// because this is used in SimpleFeed.php
if (!isset($args['url']) or !isset($input))
 return 0;

Use the more advanced format, or customize SimpleFeed.php

simplepie is not downloadable[edit]

http://simplepie.org/ >>> download >>> https://github.com/rmccue/simplepie/downloads

"Sorry, there aren't any downloads for this repository. "

Okip 00:37, 6 June 2011 (UTC)Reply[reply]

better link: http://simplepie.org/downloads/ Okip 00:40, 6 June 2011 (UTC)Reply[reply]

That link from that page to the SimplePie plugin download is also broken 14:00, 22 September 2011 (UTC)
Download the full zip from simplepie.org, and simply use the .inc file from that. It works for me with MW1.18.1--Teststudent 23:01, 31 January 2012 (UTC)


I followed the instruction and after adding I got

<feed> http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml</feed>

Please help me .

Same problem here. I also get this strange string... -- 15:33, 12 January 2012 (UTC)Reply[reply]
I believe it might be caused by some RSS feeds that do not send you the date of the feed item. You can fix it by removing the [date="h:i:s d/m/y T"] and {DATE} from the feed url line. Also, as mentioned above, in SimpleFeed.php change function parseFeed($input, $args, &$parser) to function parseFeed($input, $args, $parser). One or both of those fixed the problem, I think it was the date change but the other change helps things as well. -- 03:28, 16 November 2012 (UTC)Reply[reply]

Where can I download it?[edit]

The Github link leads nowhere.

  • You need two files to get this extension to work, SimpleFeed.php and simplepie.inc. I've put both of them up on my SkyDrive for anyone who needs at: http://skydrive.live.com/?cid=92373444895FA451&id=92373444895FA451!147
    • Note that I'm not responsible for the content of those files. I just downloaded SimpleFeed.php from a SimpleFeed link a while back and simplepie.inc from simplepie.org. Although they are working fine for me, download and use them at your own risk.

Git with simlepie.inc[edit]

Hi everybody,

we at the TDF (w:en:The Document Foundation) do use the SimpleFeed extension. I'm cleaning up the extension. It uses many deprecated functions and because of the problematic situation to get simplepie.inc, I provide our changes at Github with our modifications. Feel free to help us to expand the extension and start pull requests. You can find the repository at https://github.com/dennisroczek/simplefeed .


Dennisroczek (talk) 09:03, 6 October 2015 (UTC)Reply[reply]

MediaWiki 1.34.0 Support[edit]

  1. Create directory extensions/SimpleFeed
  2. Download SimpleFeed 1.0.23 from https://github.com/jonnylamb/simplefeed , and decompression to extensions/SimpleFeed
  3. Delete file simplepie.inc
  4. Download simplepie 1.5.4 from https://github.com/simplepie/simplepie , and decompression
  5. Copy autoloader.php and library to extensions/SimpleFeed
  6. Rename autoloader.php to simplepie.inc
  7. Create directory extensions/SimpleFeed/cache , Permissions are usually 755, 775 or 777.
  8. Edit file LocalSettings.php
-P1ayer (talk) 08:00, 4 March 2020 (UTC)Reply[reply]

Fix to MediaWiki 1.35.1 Support[edit]

  • File: /extensions/SimpleFeed/SimpleFeed.php
  • Line 66:
Fix to
-P1ayer (talk) 13:54, 2 March 2021 (UTC)Reply[reply]