我很难使用zend_feed类为我的网站创建自定义原子Feed。这是我的FeedController类。最初我尝试在$feedArray
中创建自定义命名空间,但这似乎不起作用。后来,我尝试使用registerNamespaces
,但输出并不是所需的。救救我!
public function indexAction()
{
Zend_Feed::registerNamespace('mysite','http://dev.mysite.com');
$feedArray = array (
'title' => 'my siteFeed',
'link' => 'http://dev.mysite.com/feed',
'charset' => 'UTF-8',
'entries' => array(),
);
$deals = new Application_Model_Deal();
$runningDeals = $deals->getRunning();
//print_r($runningDeals);
foreach ($runningDeals as $deal)
{
$feedArray['entries'][] = array (
'title' => $deal['title'],
'link' => 'dev.mysite.com/deals/'. $deal['slug'],
'description' => $deal['description'],
);
}
$rssFeedFromArray = Zend_Feed::importArray($feedArray, 'atom');
$rssFeedFromArray->send();
$entry = new Zend_Feed_Entry_Atom();
$entry->title = 'my custom entry';
$entry->link = 'http://dev.mysite.com/feed';
$entry->charset = 'UTF-8';
Zend_Feed::registerNamespace('mysite','http://dev.mysite.com');
$entry->{'mysite:title'} = 'Deal Title';
$entry->{'mysite:maxQuantity'} = $deal['max_purchase_individual'];
$entry->{'mysite:currentQuantity'} = 'qty';
echo $entry->saveXML();