Created
September 27, 2012 14:17
-
-
Save dimmduh/3794253 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Виджет-блок с новостями, полученными по rss | |
| */ | |
| public function widgetAction() | |
| { | |
| require_once('Zend/Feed.php'); | |
| try | |
| { | |
| $feed = Zend_Feed::import('http://www.sports.ru/rss/all_news.xml'); | |
| } | |
| catch (Zend_Feed_Exception $e) | |
| { | |
| throw new Exception('Widget - cannot load rss!'); | |
| return false; | |
| } | |
| $data = array(); | |
| foreach ($feed as $entry) | |
| { | |
| $data[] = array( | |
| 'title' => $entry->title(), | |
| 'description' => $entry->description(), | |
| 'image' => $entry->enclosure->getDom()->getAttribute('url'), | |
| ); | |
| } | |
| $this->view->data = $data; | |
| $this->getResponse()->appendBody($this->view->fetch('controller_name/widget.tpl.html' ) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment