RSS Displayer showing Google calendar events in wrong order

Permalink
I'm using an RSS Displayer to show upcoming events through a Google calendar feed, but I cannot get them to display in the correct order. Events are sorted based on when they were last edited, not on start time. I added the
orderby=starttime
query parameter (see https://developers.google.com/google-apps/calendar/v2/reference#Para... ), but it has no effect.
sortorder=ascending
(or descending) also does not work. The strange thing is that
futureevents=true
DOES take effect (shows only upcoming events).

I know my feed URL is valid, because if I paste it in a browser, all 3 query parameters work as they should. So it appears the problem may be on the Concrete5 side, like it is simply ignoring certain query parameters but accepting others.

Any help with this issue will be greatly appreciated.

Thanks,
Zach

 
A3020 replied on at Permalink Reply
A3020
I've had a similar issue once. I remember that I took a look at /libraries/3rdparty/simplepie.php.

Also check /core/helpers/feed.php. As you can see, the load() method returns a SimplePie object, so you are able to override your rss_displayer controller and edit the view() method so it will sort correctly. (see below)

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
class RssDisplayerBlockController extends Concrete5_Controller_Block_RssDisplayer {
   public function view(){ 
      $fp = Loader::helper("feed");         
      $feed = $fp->load($this->url); 
      $feed->set_item_limit( intval($this->itemsToDisplay) );
      $feed->init();
      $feed->handle_content_type();
      /*
         Do some sorting here
         Check /libraries/3rdparty/simplepie.php for available methods
      */
      $posts = $feed->get_items();
      if( $feed->error() )
webmaster55 replied on at Permalink Reply
Thank you! That did the trick. For those having the same issue, I added $feed->enable_order_by_date(false) in the view() function in my rss_displayer controller (see below).

function view(){ 
   $fp = Loader::helper("feed");         
   $feed = $fp->load($this->url); 
   $feed->set_item_limit( intval($this->itemsToDisplay) );
   $feed->init();
   $feed->handle_content_type();
   // Add this one line:   
   $feed->enable_order_by_date(false);
   $posts = $feed->get_items();
   if( $feed->error() )
      $this->set('errorMsg', t("Oops, it looks like you've entered an invalid feed address!") );
   $this->set('posts', $posts);
   $this->set('title', $this->title);
}


Of course, you still need your query parameters appended to the feed URL. In my case I'm using:

sortorder=ascending&orderby=starttime