Prev | Current Page 300 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com>
Zend Framework in Action (Ch01) Manning Publications Co. 19
foreach ($rowset as $item) { D
$channel['entries'][] = array(
'title' => $item->title,
'link' => 'http://places/article/index/id/'
. $item->id . '/',
'description' => $item->body
);
}
$feed = Zend_Feed::importArray($channel, $format); E
$feed->send(); F
$this->_helper->viewRenderer->setNoRender(); G
$this->_helper->layout()->disableLayout();
}
}
A If neither choice of RSS or ATOM feed format is requested default to RSS
B Grab a selection of articles from the database to insert into the feed (this would likely be limited but is simplified for this example)
C Build up the required elements into an array
D Build up each from the rowset retrieved from the Articles table with some minimal elements within the above array
E Import the array into Zend_Feed along with the format in which it is to be encoded
F Set the content type of the HTTP header string and output the feed
H Disable the view and layout rendering as this is is not an HTML page.
What we??™ve done in listing 11.1 is to retrieve some data from the database, put it into a multidimensional
array, then used that array to build either an RSS or ATOM feed which is then output as an XML string ready
to be digested by a newsfeed reader or aggregator.


Pages:
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
projektowanie ogrodów łódź Okna PCV Wrocław Kurs architektury wyprawy 47lw570s