We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    I was wondering why the choice to implement Magpie over Simplepie? I understand it is being implemented for the simple purpose of grabbing some feeds from this forum, but Simplepie is more actively developed and would allow for greater possibilities/extendability.
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
    • Any chance you can convert it to Simple Pie? If so and it indeed provides for better capabilities, there’s no reason at all we shouldn’t make the switch. Not speaking for Shaun, I suspect it was just the fastest route for grabbing the Important News and Security Feeds ... it took all of half an hour I think. tongue
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 14050
        • 788 Posts
        I utilized SimplePie for GoogleEvents, so I imagine I should be able to. It has a pretty straightforward API. Come Monday I have some free time, so I will see what I can do.
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
        • Very cool Jesse, and thanks!
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 28215
            • 4,149 Posts
            It was the first free open source PHP RSS converter that provided no restrictions on output formatting that came up on Google. tongue

            Feel free to implement Simplepie, if you want. Make sure to adjust modRSSParser to abstract it instead.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 14050
              • 788 Posts
              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.
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
              • Jesse:

                Do you know how to create a patch of changes in your local working copy? If so, can you provide this as a patch file, making sure you svn add (or delete) files (you can do this without commit privs since these are working copy commands) so they are included as appropriate in the patch.

                In the near future, we’ll be implementing this as a standard process so anyone can submit patches for code review by the team to be accepted/rejected for commit.
                  • 14050
                  • 788 Posts
                  I believe so. I attached it with a .txt suffix so that it could be uploaded. Let me know if I did anything wrong.
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.