For some reason, the feed I'm building keeps putting a Line Feed character at the start of the RSS output, preventing it from validating.
Here is my controller:
Code:
<?php
/**
* FeedsController
*
* This
*
* @author Shelby
* @version 1.0
*/
class FeedController extends Zend_Controller_Action {
public function indexAction() {
//
}
/**
* Builds and returns the main SDE feed.
*/
public function sdeAction() {
//disable the rendering and the layout
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout()->disableLayout();
//initialize the rss format
$format = $this->_request->getParam('format', 'rss');
$format = in_array($format, array('rss', 'atom')) ? $format : 'rss';
//grab all of the articles for this feed
$articlesTable = new Articles();
$articles = $articlesTable->getArticles();
//grab an instance of the view so we can call its url helper
$view = $this->_helper->viewRenderer->view;
$today = new Zend_Date();
//build the main channel information for this feed
$channel = array(
'title' => 'SDE',
'link' => $view->url(array('controller' => 'feed', 'action' => 'sde')),
'description' => 'Synergy Development Environment News',
'charset' => 'UTF-8',
'pubDate' => $today->get('Arpa'),
'entries' => array()
);
//add each article to the feed
foreach ( $articles as $article ) {
$channel['entries'][] = array(
'title' => $article['title'],
'link' => $view->url(array('controller' => 'articles',
'action' => 'display',
'id' => $article['id'])),
'description' => $article['description'],
'charset' => 'UTF-8',
'pubDate' => $today->get('Arpa')
);
}
//build and send the feed
$feed = Zend_Feed::importArray($channel, $format);
header('Content-Type: text/xml; charset=UTF-8');
echo $feed->saveXML();
//$feed->send();
}
}
And here is the very simple model which accesses a simple database of articles:
Code:
<?php
/**
* Articles
*
* @author shelby
* @version 1.0
*/
class Articles extends Zend_Db_Table_Abstract {
/**
* The default table name
*/
protected $_name = 'articles';
public function getArticles() {
return $this->fetchAll()->toArray();
}
}
I can't find any closing PHP tags, which might be causing a problem. Any help would be appreciated.