I don’t have commit privileges, so here is the implementation of SimplePie (attachment as all the files). It worked flawlessly on my local development machine.
Essentially,
welcome.php should look like the following:
// grab rss feeds
$modx->loadClass('xmlrss.modRSSParser','',false,true);
$rssparser = new modRSSParser($modx);
$url = 'http://modxcms.com/forums/index.php?sa=recent;type=rss2;action=.xml&limit=10;board=1';
$rss = $rssparser->parse($url);
$modx->smarty->assign('newsfeed',$rss);
$url = 'http://feeds.feedburner.com/modxsecurity';
$rss = $rssparser->parse($url);
$modx->smarty->assign('securefeed',$rss);
$modx->smarty->display('welcome.tpl');
And
modrssparser.class.php:
<?php
/**
* modRSSParser
*
* @package modx
* @subpackage xmlrss
*/
/**
* RSS Parser for MODx, implementing SimplePie
*
* @package modx
* @subpackage xmlrss
*/
class modRSSParser {
/**#@+
* Constructor for modRSSParser
*
* @param modX &$modx A reference to the modx object.
*/
function modRSSParser(&$modx) {
$this->__construct($modx);
}
/** @ignore */
function __construct(&$modx) {
$this->modx =& $modx;
$this->modx->loadClass('xmlrss.SimplePie','',false,true);
$this->feed = new SimplePie();
$this->feed->set_cache_location($this->modx->config['core_path'].'cache/rss/');
}
/**#@- */
/**
* Parses and interprets an RSS or Atom URL
*
* @param string $url The URL of the RSS/Atom feed.
* @return array The parsed RSS/Atom feed.
*/
function parse($url) {
$this->feed->set_feed_url($url);
$this->feed->init();
foreach($this->feed->get_items() as $item) {
$rss[]=array('link'=>$item->get_link(),
'title'=>$item->get_title(),
'description'=>$item->get_description(),
'pubdate'=>$item->get_local_date('%b %d, %Y %I:%H %p'));
}
return $rss;
}
}
Then upload the simplepie.class.php to the xmlrss directory.