I am trying to use ContextSwitch to allow an RSS/ATOM feed version of a
particular action in one of my controllers.
Here is what I have in the Controller init()
$this->_contextSwitch = $this->_helper->getHelper('contextSwitch');
$this->_contextSwitch->setContext('rss20', array('headers' =>
array('Content-Type' => 'application/rss+xml')));
$this->_contextSwitch->setContext('atom10', array('headers' =>
array('Content-Type' => 'application/atom+xml')));
$this->_contextSwitch->addActionContext('list', array('rss20', 'atom10'));
$this->_contextSwitch->initContext();
=========
I am looking for some ideas on how best to implement outputting an RSS/ATOM
feed with Zend_Feed_Builder.
In the particular action should i use something like
switch ($this->_contextSwitch->getCurrentContext()) {
case 'rss20':
case 'atom10':
// disable layout/viewrenderer, etc
// Build feed and output
$feed->saveXml()
break;
default:
// display regular html version
}
OR
Should I add a suffix for each rss/atom contexts and move the feed building
and output into a view script?
OR
Is there a better way?
I am very curious to see how everyone else is handling something like this?
Thanks!
--
View this message in context: http://www.nabble.com/Ideas-on-how-to-use-ContextSwitch-%2B-Zend_Feed_Builder-for-RSS-Atom-Feeds-tp20363456p20363456.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论