Jump to content

[SOLVED] Building an RSS Feed with Zend Framework?


Trooper

Recommended Posts

I can't figure out how to build an RSS feed using Zend_Feed. This is my code, but it gives me an error where the entries => $posts saying that posts is undefined. Also, FireFox just downloads it as if it were a file...its not viewing it as an rss feed. Possibly cause of this error. Any help would be great!

 

/* RSS Action
 * This generates an RSS feed from the posts
 */
public function rssAction()
{
	$db = Zend_Registry::get( 'db' );
	$postresult = $db->fetchAll( 'SELECT * FROM posts WHERE post_published=1 ORDER BY post_date DESC' );

	for( $i = 0; $i == count( $postresult ); $i++ )
	{
		$posts[$i][] = 	array (
							'title'			=> $postresult[$i]['post_headline'],
							'link'			=> 'http://192.168.0.25/index/post/id/' . $postresult[$i]['post_id'],
							'description'	=> substr( $postresult[$i]['post_copy'], 0, 100 ),
							'content'		=> $postresult[$i]['post_copy'],
							'lastUpdate' 	=> $postresult[$i]['post_date']
						);
	}

	$feeddata = array (
		'title'			=>	'Ryan\'s Blog',
		'description'  	=>	'My personal blog about what ever is on my mind...usually technology related.',
		'link'			=>	'http://192.168.0.25',
		'author'		=> 	'Ryan',
		'email'			=>	'[email protected]',
		'charset'		=>	'UTF-8',
		'copyright' 	        =>	'Copyright © 2008 Ryan Capote',
		'entries'		=>	$posts		
		);

	$feed = Zend_Feed::importArray( $feeddata, 'rss' );

	$feed->saveXML();
	$feed->send();

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.