Morning
I've put together some code to pull an RSS list of events through so we can display them on our website. I have two issues:
1.) The events are sorted by descending date for the RSS field which means the most far away events are displayed at the top of the list.
2.) There are 74 events and I only want to show 5.
So I want to display the next 5 upcoming events. Here is my code:
Page.php
class Page_Controller extends ContentController {
function RestfulLinks($url, $delimiter, $interval){
$rssfeed = new RestfulService($url,$interval);
$conn = $rssfeed->request('')->getBody();
$result = $rssfeed->getValues($conn, $delimiter);
return $result;
}
}
HomePage.php
class HomePage_Controller extends Page_Controller {
function EventList($num=5) {
$RSSFeed = RestfulLinks("http://itson.co.nz/feeds/all/", "entry", 3600);
$EventList = new DataObjectSet();
$num_items=0;
foreach($RSSFeed as $EventItem){
$extrainfo = array(
'EventTitle' => $EventItem->title,
);
$EventList -> push(new ArrayData($extrainfo));
if (++$num_items == $num) break;
}
return $EventList;
}
}
This returns the following:
* South Island U15 & U17 Badminton Championships (Monday 12th–Saturday 17th July 2010)
* Nelson Winter Music Festival - The Funky Monkeys (Monday 12th July 2010)
* 'The Ballad of Robin Hood'- Children's Theatre (Monday 12th–Tuesday 13th July 2010)
* Nelson Winter Music Festival - Josef Spacek & Michael Houstoun (Sunday 11th July 2010)
* Nelson Winter Music Festival - Kemp English (Sunday 11th July 2010)
What I'd like to return is the following:
* Nelson Farmers' Market (Wednesday 20th January 2010–Monday 31st January 2011)
* Shelter from the Storm (Saturday 24th April–Wednesday 30th June 2010)
* 'Mille-Fleurs' Art Exhibition at The Suter Art Gallery (Saturday 8th May–Sunday 20th June 2010)
* YMCA (Thursday 13th May–Saturday 31st July 2010)
* TREATY2U (Friday 14th May–Sunday 1st August 2010)
Does anyone have a good idea on how to achieve this? I can think of some pretty ugly methods but I'm hoping that the order of $RSSFeed can be easily reversed.
Thanks in advance
Tama