Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-11-2008, 08:50 PM
Junior Member
 
Join Date: Aug 2008
Posts: 3
Default Problem setting up a Feed from my MVC

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-12-2008, 07:04 PM
Junior Member
 
Join Date: Aug 2008
Posts: 3
Default

I figured it out. Turns out I had a Line Feed at the top of my Index.php file. Of course it would be something stupid like that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:24 PM.