Automagic RSS Feed Generator Plugin

by 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:
$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:
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:
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).
http://yourapp/rss/modelname
or
http://yourapp/rss/modelnames

Report

More on Plugins

Advertising

Comments

  • mattc posted on 03/03/08 08:14:41 PM
    Hey all,
    If you're using Cake 1.2 use the built in RSS support. This helper was really meant for 1.1

    -Matt
  • leop posted on 01/28/08 10:43:33 AM
    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.

  • deviser posted on 11/26/07 01:38:58 PM
    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";
  • xmihu posted on 11/11/07 07:23:11 PM
    how i do?
  • xmihu posted on 10/24/07 12:01:58 AM
    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.
  • jorge.orpinel posted on 10/20/07 01:22:54 AM
    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.
  • nextri posted on 06/06/07 03:50:37 AM
    Great plugin. Thx for this!
  • mariano posted on 04/21/07 02:29:47 PM
    As stated in The Bakery Guidelines instead of inserting a link to a foreign site please include source code in this article, and remove link. This gives the possibility of people looking at how it is implemented without having to go to a remote site and download a file. Thanks :)
login to post a comment.