About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Sharing Content With RSS

Sharing Content With RSS

Building an RSS feed for your own apps

Say you've created a custom data collection for your Sitellite-powered web site, and now you want to let your main site syndicate it.  Say it's a collection called people_i_meet that keeps a list of all the new people you meet day-to-day.

Here is some simple code to create a list of these folks, linking back to their own special page on your web site.  First, the box, which you can save to inc/app/example/boxes/peoplefeed/index.php
<?php

header ('Content-Type: text/xml');

echo template_simple (
    'peoplefeed.spt',
    db_fetch_array (
        'select
            id, concat(firstname, lastname) as name, date
        from people_i_meet
        order by date desc'
    )
);

exit;

?>
Next, the template, which you can save to inc/app/example/html/peoplefeed.spt:
<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns="http://purl.org/rss/1.0/"
>

<channel rdf:about="{site/url}/index/people-app">

    <title>People I Meet</title>
    <link>{site/url}/index/people-app</link>
    <description>
        This is a list of all the people I meet throughout my day.
    </description>

    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>

    <admin:generatorAgent
        rdf:resource="http://www.sitellite.org/v.{SITELLITE_VERSION}"
    />

    <items>
        <rdf:Seq>
{loop obj}
            <rdf:li
                rdf:resource="{site/url}/index/people-app/person.{loop/id}"
            />
{end loop}
        </rdf:Seq>
    </items>

</channel>

{loop obj}
<item rdf:about="{site/url}/index/people-app/person.{loop/id}">
    <title>{loop/name}</title>
    <link>{site/url}/index/people-app/person.{loop/id}</link>
    <dc:date>{loop/date}</dc:date>
</item>

{end loop}
</rdf:RDF>
You should now be able to view your newsfeed RSS output at the following URL:
http://www.yourWebSite.com/index/example-peoplefeed-action
And that's all there is to it.  There's much more you can add to the RSS template, but the template above should be sufficient for a simple newsfeed.  For more information, you can read the official RSS specification at the following URL:

http://web.resource.org/rss/1.0/spec

Some additional RSS extensions or compatible specifications are also available here:

Dublin Core
http://dublincore.org/

Resource Description Framework (RDF)
http://www.w3.org/RDF/

Syndication Module
http://web.resource.org/rss/1.0/modules/syndication/

Admin Module
http://webns.net/mvcb/

Creative Commons Module
http://web.resource.org/rss/1.0/modules/cc/

Page 1: RSS, which stands for Rich Site ...
Page 2: Syndicating content from another site
Page 3: Advanced content syndication
Page 4: Building an RSS feed for your own apps

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.