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 query parameter (see https://developers.google.com/google-apps/calendar/v2/reference#Para... ), but it has no effect. (or descending) also does not work. The strange thing is that 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
orderby=starttime
sortorder=ascending
futureevents=true
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
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).
Of course, you still need your query parameters appended to the feed URL. In my case I'm using:
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
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)