How to use zend_navigation to populate zend_feed?
In the bootstrap file of each of my modules I am populating my Zend_Navigation instance so that I 开发者_开发技巧can create html/xml sitemaps, side-bar navigation, admin navigation and, now, I want to create an rss feed.
Instead of duplicating code and adding the pages to Zend_Feed, is there a way to use Zend_Navigation to populate Zend_Feed?
Feeds are linear entries and do not support nested structures like Navigation.
However, Navigation Containers implement SPL Iterator Interfaces, so you can easily iterate them via foreach
to pass the pages as feed entries.
But I think the better approach would be to add new feed entries when you add your pages to navigation containers, the same way.
I extended Zend_View_Helper_Navigation to take the nav, create an array ($feed) of items that Zend_Feed would accept, and returned Zend_Feed::importBuilder(new Zend_Feed_Builder($feed), 'rss')->saveXML();
精彩评论