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'			=>	'trooper@spamex.com',
		'charset'		=>	'UTF-8',
		'copyright' 	        =>	'Copyright © 2008 Ryan Capote',
		'entries'		=>	$posts		
		);

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

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

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.