Mar 14, 2009 0
How create a feed for my Symfony project in three steps?
First step implement the zend framework
[cref 30 How can i use Zend Framework components in my Symfony project?]
Second step create a modul called feed and remove the template folder
./symfony generate:module frontend feed rm apps/frontend/modules/feed/templates/ -Rf
Third step replace the index function code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function executeIndex(sfWebRequest $request) { ProjectConfiguration::registerZend(); $feedArray = array( 'title' => ..., 'link' => $this->generateUrl('default_index', array('module' => 'feed')), 'description' => .., 'language' => ..., 'charset' => sfConfig::get('sf_charset'), 'pubDate' => time(), 'entries' => array() ); /* get the data from the db or outher source */ foreach($articles as $article) { $feedArray['entries'][] = array( 'title' => $article['title'], 'link' => $this->generateUrl('article_detail', $article), 'guid' => $article['id'], 'description' => $article['description'] ); } $feed = Zend_Feed::importArray($feedArray, 'rss'); $feed->send(); throw new sfStopException(); } |
that’s all for more Information see


Recent Comments