CakePHP rss reader component installation
Hi all !
Today I’ve installed an RSS Reader Component in my cake application, so you can read the news at login time.
How ?
First, after searching cake community (bakery), I located this CakePHP RSS component
Following the instructions (very easy), you download the component into your vendors and components folder, then use it to get the feed, and display it as you like.
Tip: Cake has a funtion “truncate” inside the Text Helper to aid you if you like to get the first N characters for a headline or description of your feed.
Here is the code I’ve used
#CONTROLLER
var $helpers = array('Javascript','DAuth', 'Text');
var $components = array('DAuth','RequestHandler', 'Simplepie');
...... code ......
$items = $this->Simplepie->feed('http://blog.allmythingstodo.com/rss');
$this->set('feeds', $items);
#END OF CONTROLLER
#VIEW
<?php
foreach($feeds as $feed) {
echo $html->link($feed->get_title(), $feed->get_permalink()) . '<br/>';
echo $text->truncate($feed->get_description());
}
?>
#END OF VIEW