//Create an array for our feed $feed = array(); //Setup some info about our feed $feed['title'] = "ZendCoding.com's Newest Stories"; $feed['link'] = 'http://www.zendcoding.com/newest-stories.rss'; $feed['charset'] = 'utf-8'; $feed['language'] = 'en-us'; $feed['published'] = time(); $feed['entries'] = array();//Holds the actual items //Loop through the stories, adding them to the entries array foreach($stories->fetchAll($select) as $story){ $entry = array(); //Container for the entry before we add it on $entry['title'] = $story->title; //The title that will be displayed for the entry $entry['link'] = $story->url; //The url of the entry $entry['description'] = $story->teaser; //Short description of the entry $entry['content'] = $story->description; //Long description of the entry //Some optional entries, usually the more info you can provide, the better $entry['lastUpdate'] = $story->modified; //Unix timestamp of the last modified date $entry['comments'] = $story->commentsUrl; //Url to the comments page of the entry $entry['commentsRss'] = $story->commentsRssUrl; //Url of the comments pages rss feed $feed['entries'][] = $entry; }
Импорт в поток
$feedObj = Zend_Feed::importArray($feed, 'rss'); //Or importArray($feed, 'atom');
Вывод
//Return the feed as a string, we're not ready to output yet $feedString = $feedObj->saveXML(); //Or we can output the whole thing, headers and all, with $feedObj->send();
Комментариев нет:
Отправить комментарий