Chapter 38. Using RSS Newsfeed Blocks


Let's talk about RSS, shall we? RSS stands for, depending on who you ask, Really Simple Syndication. The whole idea behind it is that sites can expose their content for syndication by other Web sites. Essentially, a site posts a special XML-formatted version of its content headlines. Other sites can download that XML and display those headlines as links back to the original site.

An example might be a better way to explain this. Swing over to http://news.yahoo.com, and scroll down to nearly the bottom of the page, shown in Figure 38.1. Notice that they have a complete section, News via RSS, with items that carry an XML icon. Other sites use an RSS icon, but the results are the same.

Figure 38.1. Exploring RSS newsfeeds at news.yahoo.com.


Click on one of these RSS or XML items, and you'll see a page like the one shown in Figure 38.2 (it'll look different in different Web browsers).

Figure 38.2. An RSS news file.


This XMLthat's what you're looking atdescribes the site and its headlines, and provides URLs, or links, back to the full news story. You can use an RSS aggregator, such as SharpReader (www.sharpreader.com), to download these RSS files, or feeds, and display them on your computer. You can also use PHP-Nuke.

What you need to do is to find an RSS feed that you want displayed in a block on your Web site. Figure 38.2 shows an RSS URL from Yahoo! News, which is http://rss.news.yahoo.com/rss/business. Go into the Blocks item in your PHP-Nuke Administration menu. As shown in Figure 38.3, provide a title for the block and fill in the RSS URL that you copied from your Web browser. Set the block's position and, if desired, expiration, and hit Create Block. The results are shown in Figure 38.4: a listing of headlines from Yahoo! News. Clicking a headline takes you straight to the Yahoo! site, where the full story is displayed. By default, PHP-Nuke downloads the headlines every hour; you can change that in the block's configuration, if desired.

Figure 38.3. Creating an RSS newsfeed block.


Figure 38.4. Viewing an RSS newsfeed block.


Notice in Figure 38.3 that the text box for the RSS URL has an adjacent drop-down list and a Setup link. Here's how that works: PHP-Nuke comes bundled with a bunch of RSS URLs, which are listed in the drop-down list. You can just select one of these when creating an RSS newsfeed block rather than typing your own URL. You can click the Setup link to add your own RSS URLs to the drop-down list box. Why bother?

Because users can also set up their own private RSS newsfeed in the Your Account module. They, too, get to select from the drop-down list of preconfigured RSS URLs, so you might want to populate that list with RSS URLs that pertain to your site. If you're stuck trying to find URLs that pertain to your site's topic, check out an RSS directory like the one at www.2rss.com, which lists RSS URLs by category.

And here's an especially cool feature: You have your own RSS feed. Other Web sites can visit www.yoursite.com/backend.php, and they'll get an RSS newsfeed of your site's News module articles. Remember, all they get is the headlines; they have to actually visit your site to read the whole story, which can help drive attendance to your site. Figure 38.5 shows the RSS feed from my sample Web site at www.scriptinganswers.com/cms2; you can see some of the News items on the site listed here in the XML.

Figure 38.5. An RSS news file produced by PHP-Nuke.


So that you can get a better idea of how this RSS stuff works, here's a sample RSS file:

 <rss version="0.91">  <channel>   <title>Daisy&#039;s Recipe Station</title>   <link>http://yoursite.com</link>   <description>PHP-Nuke Powered Site</description>   <language>en-us</language>   <item>    <title>New Cookware from Revelie!</title>    <link>     http://yoursite.com/modules.php?name=News&file=article&sid=3    </link>   </item>   <item>    <title>Computers and Cooking</title>    <link>     http://yoursite.com/modules.php?name=News&file=article&sid=2    </link>   </item>   <item>    <title>Apple Pies</title>    <link>     http://yoursite.com/modules.php?name=News&file=article&sid=1    </link>   </item>   </channel> </rss> 

The file begins with the title, URL, and description of your site: These are all set up in the site's Preferences administration module. The site's default language is also configured in Preferences. Next is an <item> tag for each News item included in the feed; each <item> includes a headline in the <title> tag and the URL to the full story in the <link> tag. And that's it!

Why bother including RSS newsfeeds on your site? First, they're a great way to add some extra content to your site, thus attracting more users, without doing any work. They're a service to your users, helping them to stay informed about whatever topic your site focuses on. Try not to get carried away, of course; one or, at most, two RSS blocks are more than sufficient for most sites.

Sidebar . FAQ

My RSS blocks are outdated. Why?

PHP-Nuke can be configured to reload the RSS content every hour, every 24 hours, or for other intervals. PHP-Nuke stores, or caches, the content in its database so that PHP-Nuke doesn't have to go get the RSS content for each user who visits your Web site. This behavior significantly improves PHP-Nuke's performance, but it also means that your RSS newsfeeds can be a few hours out of date from time to time (which is unusual, most sites don't update their RSS feeds more than every hour or so).

Where can I get an RSS newsreader to test my own RSS feeds?

There are lots of RSS readers, or aggregators, out there; try searching Google for one. You can also grab Thunderbird from www.mozilla.org; it's a combination e-mail client, news reader, and RSS aggregator that's great for testing PHP-Nuke's RSS capabilities.

Okay, I'll bite. What's XML?

XML stands for eXtensible Markup Language. Really, it's just a set of rules for creating languages like RSS. XML is interesting because it creates self-describing data. In other words, when you look at an RSS document like the previous one, it's pretty easy to pick out the titles because each one is surrounded by <title> and </title>. Those elementscalled tagsare self-descriptive. XML is just the set of rules that says you have to have an opening (<title>) and closing (</title>) tag, for example.

Where can I find more RSS newsfeeds?

Search for them. They're constantly changing, and no one site is a complete directory to them all. Hop on Google and search for "RSS feed," throwing in any keywords that describe the topics you're interested in.




    PHP-Nuke Garage
    PHP-Nuke Garage
    ISBN: 0131855166
    EAN: 2147483647
    Year: 2006
    Pages: 235
    Authors: Don Jones

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net