Smutty

MVC Framework

SmuttySyndication

Smutty offers you the option of automatically having RSS feeds created for your models (Atom support will also be added).

Enabling Syndication

To enable syndication for a model you just have to set a few attributes to it's $rss property.

class Page extends Smutty_Model {

    var $rss = array(
        title => 'name',
        description => 'body',
        id => 'name',
        url => array(
            controller => 'wiki',
            name => 'name'
        )
    );

}

The first parameters to notice are the title, description and id fields. These tell Smutty which field of from your model to use when creating the feed. They can be left out if they're named some thing common, Smutty will try and guess them for you ("something normal" being eg. title = title, subject, name, etc...).

Next is the URL parameter and tells Smutty how to link back to this item. The names controller and action are special and refer to the controller and action to use. All the other values in the URL and mappings of the name of the URL attribute, and the corresponding model field. So, from the example above you can see name => 'name'. This tells Smutty to use the models name field for the name parameter in the URL (which is a custom route).

Adding To Your Template

When you have set up the above and your model is ready for syndication, you can create a link to the feed by using the {rss} function in the <head> of your page.

<html>
<head>
<title>My Page</title>

{rss model="Page"}

</head>

Links: Post a comment

Useful Pages

Links