Creating a RSS feed using Zend::Feed
The Zend Framework makes consuming RSS feeds an extremely simple task, but you can just as easily create an RSS (and Atom) feed from by importing from an array and then export as RSS/Atom . You first start off by creating a array containing your channel data:
<?php
$channel = array(
'title' => '',
'link' => '',
'description' => '',
'charset' => '',
'entries' => array()
);
?>
Once that's been set up you populate the $channel['entries'][] array by iterating over your datasource which might be something like:
<?php
foreach( $this->journalEntries as $entry ) {
$publishedDate = new DateTime( $entry['date'] );
$channel['entries'][] = array(
'title' => '',
'link' => '',
'description' => '',
'pubDate' => $publishedDate->format('U'),
'guid' => /* If null, link used */
);
}
?>
Now with our array correctly populated we import and display using Zend_Feed
<?php
$feed = Zend_Feed::importArray( $channel, 'rss' );
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$feed->send();
?>