Prev | Current Page 299 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

0.1 then you??™d have followed that to the ATOM syndication
format. If you did that while under the pressure of a deadline and realised that all of those formats are
potentially in use amongst the millions of syndicated sites you??™d have probably sat down in a cold sweat!
Of course, once you calmed down, you??™d likely realise that all you need do is to pick the latest and greatest
formats and concentrate on outputting those. Thankfully, even that isn??™t needed as Zend_Feed can take care of
the format for you leaving you to simply pass it the data it needs for your feed. In listing 11.1 we demonstrate a
very simple controller action that produces an RSS (2.0) or ATOM feed.
Listing 11.1 A feed producing controller action
require_once 'Zend/Feed.php';
require_once 'models/ArticleTable.php';
class FeedController extends Zend_Controller_Action
{
public function indexAction()
{
$format = $this->_request->getParam('format');
$format = in_array($format,
array('rss', 'atom')) ? $format : 'rss'; A
$articlesTable = new ArticleTable(); B
$rowset = $articlesTable->fetchAll(); B
$channel = array( C
'title' => 'Places',
'link' => 'http://places/',
'description' => 'All the latest articles',
'charset' => 'UTF-8',
'entries' => array()
);
Licensed to Menshu You

Pages:
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
agroturystyka bory tucholskie Gallery of Bialowieza Pozycjonowanie twojemiastopoznan.pl Odżywki