GTD Tools - AllMyThingsTodo

March 20, 2008

CakePHP rss reader component installation

Filed under: cakephp — admin @ 1:23 pm

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

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress