Automagic RSS Feed Generator Plugin

By Matt Curry (mattc)
Automatically create RSS feeds for your CakePHP app.
A .zip of the plugin is available at http://sandbox.siteamonth.com/demo/rss
1. Download FeedCreator 1.7.2-ppt(http://sourceforge.net/projects/feedcreator/) and put the feedcreator.class.php file in /app/vendors/feedcreator.

2. Download the plugin and unzip the contents to app/plugins. The plugin is called "rss", so make sure there is no conflict with any other controllers/plugins

3. Add this to your /app/config/routes.php:
Download code $Route->connect('/rss/*', array('controller' => 'rss', 'action' => 'feed'));

4. You have to allow permission for the plugin to generate a feed for a particular model. Edit your model to include:
Download code var $feed = true;

5. The plugin will attempt to find default values for the feed.
If your model includes a field 'title' or 'name' that will be used automatically for the item title.
The fields 'desc', 'description', 'text', 'content' or 'body' will be used for the item description.
The link will be '/{$model}/view/{$model->primaryKey}' by default.
The results will be ordered by 'created' => 'DESC' by default.
The limit is set to 10 by default.
You can override any of these in the model, as well as set conditions for which rows are returned, by replacing the line used in step #5 with:
Download code var $feed = array(
    'conditions' => array('Post.active' => true),
    'titleField' => 'Post.name',
    'descField' => 'Post.desc',
    'link' => '/post/view/%s',
    'orderby' => array('Post.created' => 'DESC'),
    'limit' => 10
);

6. You reach the feed using both the singular and plural model name (post or posts).
Download code http://yourapp/rss/modelname
or
Download code http://yourapp/rss/modelnames

 

Comments 234

CakePHP Team Comments Author Comments
 

Comment

1 Awesome

Great plugin. Thx for this!
Posted Jun 6, 2007 by Thomas Pedersen
 

Comment

2 The sources are unaccessable

The link http://sandbox.siteamonth.com/demo/rss is unaccessable. At least right now. Could you paste the sources into the article? or email me the source pls. jop@levogiro.net tnx.
Posted Oct 20, 2007 by Jorge Orpinel
 

Question

3 how to set encoding

the default encoding is ISO-8859-1, but i want to use UTF-8

in rss.thtml

$rss = new UniversalFeedCreator();
$rss->encoding = "UTF-8";

it's not work, who can help me? thanks.
Posted Oct 24, 2007 by xmihu
 

Comment

4 dont work in cake1.2

how i do?
Posted Nov 11, 2007 by xmihu
 

Comment

5 set encoding to UTF 8

To set utf-8 you must change line 626 in feedcreator.class.php file:

default value: var $encoding = "ISO-8859-1";

replace with this:

new value: var $encoding = "UTF-8";
Posted Nov 26, 2007 by Stefan
 

Question

6 how do I get access to this plugin

I'm having real problems with this, mainly down to me being a cake newbie, not understanding how the plugins feature works and probably also that I'm using 1.2.

I just get a controller missing error. Do I need to declare the plugin in the same way that I do with helpers and components?

I tried to get this info from the manual, but 1.1 is vague and 1.2 is vaguer.

Please help as this plugin is just what I'm looking for.

Posted Jan 28, 2008 by leo ponton
 

Comment

7 CakePHP 1.2

Hey all,
If you're using Cake 1.2 use the built in RSS support. This helper was really meant for 1.1

-Matt
Posted Mar 3, 2008 by Matt Curry