Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created September 27, 2012 14:17
Show Gist options
  • Select an option

  • Save dimmduh/3794253 to your computer and use it in GitHub Desktop.

Select an option

Save dimmduh/3794253 to your computer and use it in GitHub Desktop.
/**
* Виджет-блок с новостями, полученными по 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