RSS feeds are still rather new to most internet users. Therefore, this tutorial is intended to help webmasters create an RSS feed and implement on their web site(s).
It's January 2006 as I write this and I fully expect that RSS feeds will become an integral part of the average user's internet experience soon. That is with the advent of Microsoft's next operating system, Windows Vista, RSS feeds will be closely integrated with all of Microsoft's operating system and business applications. Likewise, other major internet entities like Google, Yahoo, eBay, and Amazon are all developing features which incorporate RSS. I expect that this type of syndication will be very common and change the way we use the internet. The only caveat I suppose is that the actual name might be changed. For example, if Microsoft chooses to call RSS feeds "Active Items" or something else they consider "intuitive", then the term "RSS Feed" might quickly become obsolete, but the technology won't change much if at all.
Case Study: "Top 5 Most Recent Listings"
For the purpose of this tutorial, we will create an RSS feed which serves the five (5) most recent listings.
We will perform the following actions:
Create a Jet-SQL query which creates a list of the five (5) most recent listings from 20/20 DataShed's Microsoft Access database for use with a new RSS feed.
Create the RSS feed (using the query from #1 above) and configure options to update the RSS data on a regular schedule.
Demonstrate how that RSS feed can be incorporated into a web page using Javascript.
Discuss other applications for the new RSS feed (which can help drive traffic to specific listings).
Create a Jet-SQL query which creates a list of the five (5) most recent listings from 20/20 DataShed's Microsoft Access database for use with a new RSS feed.
20/20 DataShed uses queries to select items from the database. The queries should be structured carefully to combine the proper data into the fields required by the RSS files. You can read more later about creating your own queries, but for now we'll use an example query that we've created.
Login to 20/20 DataShed on your web site (with administrative privelages).
Click on the "SQL Reports" link in the menu. (Using the SQL Reports utility we can test the query and ensure that it produces the type of information we want -- before creating the RSS feed.)
Click the "Build New Report" button. (You will see a large textarea box and a "Go »" button.)
Copy-n-paste the following query into that textarea box.
SELECT TOP 5 tempQuery.species &' '& tempQuery.genus AS title, 'listings.asp?itemID='& tempQuery.itemID AS link, tempQuery.general_description AS description, Trim(tempQuery.family &' '& tempQuery.order) AS category, (SELECT TOP 1 CStr(item_images.imageURL) FROM item_images WHERE item_images.itemID=tempQuery.itemID AND item_images.isPhoto ORDER BY item_images.order_number) as enclosure, CDbl(tempQuery.date_lastmodified) AS pubDate, tempQuery.phylum AS [dc:creator] FROM items AS tempQuery INNER JOIN (categories INNER JOIN category_item_link ON categories.categoryID=category_item_link.categoryID) ON tempQuery.itemID=category_item_link.itemID WHERE categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) ORDER BY tempQuery.date_entered DESC;
Click "Go »". If the query works properly then you'll see a table with columns and rows displaying data that will be used in the RSS feed file. If the query doesn't work, then you might see an error message -- try again or input a different query.
Create the RSS feed (using the query from #1 above) and configure options to update the RSS data on a regular schedule.
From the "SQL Reports" page (as in Step 1), click on the "Send to RSS Manager" button. You will see a the "Create New RSS Feed" form. Some of the fields will be filled in automatically, but all of the fields can be altered as you please.
Adjust the input in each form field as you please...but we recommend that you follow the "Tips" carefully -- those tips will help you ensure that relevant information is provided in your RSS feed.
We will adjust the fields as follows:
*
Tip...
*
Tip...
*
Tip...
Tip...
Tip...
*
Tip...
Tip...
Tip...
Tip...
*
Tip...
Yes
No
Tip...
Yes
No
Tip...
*
Tip...
*
Tip...
Tip...
Note that the "Query" field contains the query that you copy-n-pasted from the previous step.
Also note that this particular feed will be rebuilt once per day.
When you finished adjusting the fields to your liking, then finish by clicking the "Build RSS Feed" button.
The new RSS feed options will be added to 20/20 DataShed and you then see a full list of your RSS feeds.
Note that the new rss feed appears last in the list above.
Also notice that the "Last Build" date is empty. That means that the RSS feed file has not yet been created. To ensure that the file is created for the first time, you can click on the "small hammer" () icon.
From now on, 20/20 DataShed will rebuild that RSS feed file once per day.
In the next steps, we'll discuss how you can use that file.
Demonstrate how that RSS feed can be incorporated into a web page using Javascript.
20/20 DataShed provides a page which lists all of the available RSS feeds on your web site and provides basic instructions to incorporate the feed into other pages.
In this screenshot you can see the "RSS Feeds" link and the new RSS feed that we've created in this tutorial.
However, we will demonstrate in detail how to incorporate your new RSS feed into a web page using Javascript.
The first task is to build the Javascript code which will grab the RSS feed from your web site and display the data in a web page.
Open any of your web pages in a text editor like Notepad. (You might also use an editor like Frontpage or Dreamweaver for this purpose.)
Copy-n-Paste the following Javascript code into that web page where you want the information to appear. The code bits that you should edit are in written in bold-blue font.:
<script type="text/javascript">
<!--
//<![CDATA[
// define the name of a target frame below
var target = '_self';
// define the ID number of the feed you want to syndicate
var strFeedID = '3';
// define the maximum length of the description or leave blank = '';
var strLengthOfDescription = '255';
// define the maximum number of items to display
// leave at zero to show all items.
This example contains fictional items and is designed to display how 20/20 DataShed can produce RSS feeds - this example RSS feed displays the five (5) most recent items.
Power Steering, Power Brakes, Ball Or Receiver Hitch, Towing Package, Sliding Rear Window, Side Molding, Fog Lights, Step Bumper, Tool Box, Winch, 4x4 Off Road Package
The code above produces a rather boring output. But with CSS, almost anything is possible. The examples below demonstrate how CSS can be used to alter the layout and cosmetics of the HTML.
You can grab the CSS used in these examples. Right-click » View Source » and then look in the <head> section of this page for the "cssExamples" snippets.
More Help With the CSS
Detailed instructions and lot's more style examples can be found in the RSS Featured Listing (Free) documentation.
Discuss other applications for the new RSS feed (which can help drive traffic to specific listings).
By using the Javascript code in Step 3 above, your RSS feed can be displayed on any web page anywhere on the internet (like a banner!) and will drive traffic to your web site. To do this, we recommend that you construct a particular CSS that suits your web site and then provide your affiliates with detailed instructions to paste the Javascript code and your preferred CSS into their web pages.
You can use the RSS feed tools to create your own "Featured Listings" banner for your own web site. This is discussed further in our free downloadable tutorial and plug-in: RSS Featured Listing (Free).
And the true genius of RSS is that all visitors to your web site who use an RSS-compatible browser (sometimes called RSS aggregators) can easily discover and subscribe to your RSS feeds whenever they want -- you don't have to do anything! By doing this, content from your web site is streamed directly to their RSS browser whenever they want it -- and how they want it! Many large web sites for real estate, news, entertainment, blogs, discussion forums, etc. are incorporating RSS feeds to provide visitors of their web sites with easy access to the most recent or most prominent information on the web site.
Modifying this Example Query (Creating Your Own RSS Feeds)
Displaying Different Data Fields
The RSS specification requires very specific fields. Based on our research and policies we have created 20/20 DataShed to take advantage of the following RSS elements for items. As well, we have made some executive decisions about which fields to use to populate each element. However, depending on the particular query you use it's possible to incorporate any of the fields from the "items" table, "people" table, "categories" table, and the "item_images" table.
<title>
The title of the item.
In the example query used in this tutorial, this element contains the "genus" and "species" fields from the "items" table. Like this:
tempQuery.species &' '& tempQuery.genus AS title
In other words, this syntax means "use the data from the species and genus fields as the title".
Alternate suggestion:
tempQuery.display_title AS title
<link>
The hyperlink or URL of the item.
In the example query used in this tutorial, this element contains a URL pointing to the full details of the item in the "listings.asp" page of 20/20 DataShed on your web site. Like this:
'listings.asp?itemID='& tempQuery.itemID AS link
In other words, this syntax means "build a hyperlink to this itemID at the listings.asp page".
We recommend that you do not alter this syntax - the itemID field is the most reliable way to link directly to an item in your database.
<description>
A brief description of the item.
In the example query used in this tutorial, this element contains the "general_description" field from the "items" table. Like this:
tempQuery.general_description AS description
In other words, this syntax means "use the data from the general_description fields as the description".
Alternate suggestion:
Trim(tempQuery.species &' '& tempQuery.genus &': '& tempQuery.general_description) AS description
<category>
Categorization of this item.
In the example query used in this tutorial, this element contains the "family" and "order" fields from the "items" table. Like this:
Trim(tempQuery.family &' '& tempQuery.order) AS category
In other words, this syntax means "use the data from the family and order fields (then Trim() it to get rid of empty spaces) as the category".
Alternate suggestion:
categories.categoryname AS category
<enclosure>
Media, such as an image.
In the example query used in this tutorial, this element contains the URL of an image on your web site associated with the item. Like this:
(SELECT TOP 1 CStr(item_images.imageURL) FROM item_images WHERE item_images.itemID=tempQuery.itemID AND item_images.isPhoto ORDER BY item_images.order_number) as enclosure
In other words, this syntax means "get the TOP 1 image associated with this item from the item_images table and use it as the enclosure".
We recommend that you do not alter this syntax.
<pubDate>
The date the item was published on the internet. (Or perhaps the date the item was most recently updated -- REpublished.)
In the example query used in this tutorial, this element contains the "date_lastmodified" field from the "items" table. Like this:
CDbl(tempQuery.date_lastmodified) AS pubDate
In other words, this syntax means "get the date_lastmodified field (and convert it to a "Double with CDbl()) and use it as the pubDate". (This "double" is process later by 20/20 DataShed to produce the date and time in GMT format.)
We recommend that you do not alter this syntax. The date_lastmodified field is the most sensible field to use to produce an accurate "pubDate".
<dc:creator>
The name or description of the "creator" of the item.
In the example query used in this tutorial, this element contains the "phylum" field from the "items" table. Like this:
tempQuery.phylum AS [dc:creator]
In other words, this syntax means "use the data from the phylum field as the dc:creator".
Alternate suggestion:
Trim(tempQuery.family &' '& tempQuery.order) AS [dc:creator]
In cases where the creator is a person (like an agent) you could use the people.firstname and people.lastname fields...but the "people" table is not incorporated in the example query used in this tutorial.
Selecting Different Items for Your Feed: Conditional Query Examples
The example query used in this tutorial incorporates a conditional "WHERE" claus:
WHERE categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) ORDER BY tempQuery.date_entered DESC;
In english, that means:
"Use data from the tables where the category is a main category, and the item is approved and displayed publicly on the web site, and the item has not yet expired."
oh..."and sort the results by the date the item was added to the database in descending order (most recent listings first!)"
It's possible however to incorporate any "conditions" that you want. For example, you might want:
Listings that belong to a specific category, like "Used Cars":
WHERE categories.categoryname='Used Cars' AND categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) ORDER BY tempQuery.date_entered DESC;
Listings that created by a specific manufacturer, like "BMW":
WHERE tempQuery.phylum='BMW' AND categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) ORDER BY tempQuery.date_entered DESC;
The options are truly endless and depend on how well you understand the Jet-SQL syntax. If you get stumped, contact us! We can create custom queries for you to use on a pay-per-service basis.
More Query Examples
All Items of a Specific User
SELECT Trim(tempQuery.family &' '& tempQuery.order) AS title, 'listings.asp?itemID='& tempQuery.itemID AS link, tempQuery.general_description AS description, categories.categoryname AS category, (SELECT TOP 1 CStr(item_images.imageURL) FROM item_images WHERE item_images.itemID=tempQuery.itemID AND item_images.isPhoto ORDER BY item_images.order_number) as enclosure, CDbl(tempQuery.date_lastmodified) AS pubDate,Trim(people.firstname &' '& people.lastname) AS [dc:creator] FROM people INNER JOIN ((items AS tempQuery INNER JOIN people_item_link ON tempQuery.itemID = people_item_link.itemID) INNER JOIN (categories INNER JOIN category_item_link ON categories.categoryID = category_item_link.categoryID) ON tempQuery.itemID = category_item_link.itemID) ON people.peopleID = people_item_link.peopleID WHERE categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) AND people.peopleID=4 ORDER BY tempQuery.itemID;
Note that you can adjust the peopleID as you please.
AND people.peopleID=1
AND people.peopleID=510
All Items of a Specific Phylum (Usually "Manufacturer" or "Country" or other top-level classification)
SELECT Trim(tempQuery.family &' '& tempQuery.order) AS title, 'listings.asp?itemID='& tempQuery.itemID AS link, tempQuery.general_description AS description, categories.categoryname AS category, (SELECT TOP 1 CStr(item_images.imageURL) FROM item_images WHERE item_images.itemID=tempQuery.itemID AND item_images.isPhoto ORDER BY item_images.order_number) as enclosure, CDbl(tempQuery.date_lastmodified) AS pubDate,Trim(people.firstname &' '& people.lastname) AS [dc:creator] FROM people INNER JOIN ((items AS tempQuery INNER JOIN people_item_link ON tempQuery.itemID = people_item_link.itemID) INNER JOIN (categories INNER JOIN category_item_link ON categories.categoryID = category_item_link.categoryID) ON tempQuery.itemID = category_item_link.itemID) ON people.peopleID = people_item_link.peopleID WHERE categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) AND tempQuery.phylum='Honda' ORDER BY tempQuery.itemID;
Note that you can adjust the phylum as you please.
AND tempQuery.phylum='Canada'
AND tempQuery.phylum='USA'
AND tempQuery.phylum='GMC'
AND tempQuery.phylum='O''Reilly''s'
All Items in Specific Categories
SELECT Trim(tempQuery.family &' '& tempQuery.order) AS title, 'listings.asp?itemID='& tempQuery.itemID AS link, tempQuery.general_description AS description, categories.categoryname AS category, (SELECT TOP 1 CStr(item_images.imageURL) FROM item_images WHERE item_images.itemID=tempQuery.itemID AND item_images.isPhoto ORDER BY item_images.order_number) as enclosure, CDbl(tempQuery.date_lastmodified) AS pubDate,Trim(people.firstname &' '& people.lastname) AS [dc:creator] FROM people INNER JOIN ((items AS tempQuery INNER JOIN people_item_link ON tempQuery.itemID = people_item_link.itemID) INNER JOIN (categories INNER JOIN category_item_link ON categories.categoryID = category_item_link.categoryID) ON tempQuery.itemID = category_item_link.itemID) ON people.peopleID = people_item_link.peopleID WHERE categories.supercategory AND tempQuery.show_on_website And tempQuery.approved_for_display AND ((CDbl(tempQuery.closing_date)>CDbl(Now())) Or (CDbl(tempQuery.closing_date)=0)) AND category_item_link.categoryID=1 ORDER BY tempQuery.itemID;
Note that you can adjust the categoryID as you please.
AND category_item_link.categoryID=1
AND category_item_link.categoryID=68
AND (category_item_link.categoryID=1 AND category_item_link.categoryID=7) To select items which are associated with two categories: like "Residential" and "Bungalow" for example.