About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Sharing Content With RSS

Sharing Content With RSS

Advanced content syndication

Say you want to do something other than simply turn an RSS newsfeed into a bulleted list in your web site's sidebar.  At this point, you're going to have to get down to the PHP level and write yourself a box.  Fortunately, Sitellite makes this easy to do with the saf.XML.RSS.Simple package, which contains an RSS retrieval class called SimpleRSS.

SimpleRSS defines only one method, fetch(), which returns an XMLDoc (see saf.XML.Doc) object tree of the specified newsfeed, and features one key built-in nicety: Automatic caching of the resulting object, either based on a specified interval, or on the syn:updatePeriod and syn:updateFrequency values from the newsfeed itself (the default).  If update instructions are not found in the newsfeed, SimpleRSS defaults to caching for an hour (3600 seconds).

Here is a quick example of retrieving a newsfeed and working with it:
<?php

loader_import ('saf.XML.RSS.Simple');

$rss = new SimpleRSS;

// fetch the newsfeed using the default 'auto' caching
$doc =& $rss->fetch ('http://slashdot.org/index.rss');
if (! $doc) {
    echo 'Error: ' . $rss->error;
    return;
}

// set the page title
page_title ('Slashdot Articles');

// retrieve a list of items using a standard XPath query
$items = $doc->query ('/rdf:RDF/item');

// turn the items into standard objects to keep it simple
foreach ($items as $key => $item) {
    $items[$key] = $item->makeObj ();
}

// display the token bulleted list -- hey, this is only an example! ;)
echo template_simple (
    '<ul>
        {loop obj}
            <li><a href="{loop/link}">{loop/title}</a></li>
        {end loop}
    </ul>',
    $items
);

?>
You can save and run the above code by dropping it into a Sitellite box script.  For example, saving the script to inc/app/example/boxes/simplerss/index.php will allow you to access it at:
http://www.yourWebSite.com/index/example-simplerss-action
For more information on manipulating the resulting XMLDoc object, check out the SAF documentation at http://www.sitellite.org/docs/ under the XML section.

Publishing RSS from common Sitellite apps

Most Sitellite apps have RSS publishing capabilities built-in, to make it easy to allow other sites to syndicate your content (free promotion) or to allow you to do cool things with multiple sites of your own.  For example, you could have a portal site that displays the top headlines from each sub-site, and perhaps the newest SiteLinks listings as well, or the latest SiteForum forum activity, or a list of file downloads from your Web Files, or a list of upcoming events from SiteEvent, and the list goes on.

Since it's really that simple, there's not much more I can say about that, so I'll move on to the next topic now. :)

Next: Building an RSS feed for your own apps

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

All Tutorials

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.