Zend Framework
Usando Zend_Feed no site!
Na home page do site de pré-lançamento da SON (School of Net), iremos exibir os últimos posts deste blog.
Para isso tivemos que utilizar o Zend_Feed.
Veja abaixo como utilizamos isso:
No indexController.php
public function indexAction() { $filter = new Zend_Filter_StripTags ( ); $this->view->use_content = true; try { $blogSon = Zend_Feed::import ( 'http://www.schoolofnet.com.com/index.php/feed/' ); // Loop through the items in the feed $items = array ( ); $i = 0; foreach ( $blogSon as $item ) { if ($i < 5) { $items [] = array ( 'title' => $item->title (), 'link' => $item->link (), 'description' => $filter->filter($item->description ()), 'pubDate' => new Zend_Date($item->pubDate ()) ); }; $i ++; } $this->view->rss = $blogSon; $this->view->posts = $items; } catch ( Zend_Feed_Exception $e ) { // feed import failed echo "Exception caught importing feed: {$e->getMessage()}n"; exit (); }
Na View (index.phtml)
ÚLTIMOS POSTS EM NOSSO BLOG
- – ()
- posts as $post): ?>
Acredito que esse código é simples. Caso tenham alguma dúvida quanto a isso, por favor, façam um comentário.