RSS Feeds – ASP Display

Yep, the server team turned on ASP for all pages on legacy college sites, even if they have a .html extension. Where an AJAX fed page will load right away and then call out to the server for your feed, an ASP fed page will not load until all the entire page is ready.

Why use ASP over AJAX?

  • The contents of an ASP feed will be indexed by search engines, AJAX will not. This is why ASP feeds are great for profile pages.
  • Contents of an ASP feed can be manipulated with JavaScript that already exists on your page, AJAX needs to have JavaScript set up in the XSLT to work.

You only need three things to make an ASP feed.

  1. Prepare your page with one line calling to an ASP parser.
  2. Insert a snippet of ASP in your page and set the variables.
  3. Some elbow grease and or moxie!

OK the third item is really about having something to feed in and an XSLT to transform the feed. No worries though! Samples will be provided on this page so grab a bag of Skittles and a Mountain Dew we are going to get crazy.

1. Prepare Your Page

This will work on .asp, .html, .aspx or just about any other type of page. In fact you can convert your old AJAX feed pages to this ASP method if you like.

Somewhere in the document you need this line of code:

<!--#include virtual="/attributes/rssParser/Functions.asp"-->

It can go in the head, in the body, even right before where the feed should appear in the code. All this does is point to the ASP parser so that your page is ready to receive an RSS feed.

Note: You can include this in your DWTs, be sure to use a root-relative link!

2. The Code Snippet

Paste the ASP code snippet in the body of your page where you want the feed to appear.

Copy and paste this into your code view!

<%
GetRSSFeed "http://myfeed.xml","/MyXSLT.xslt","My Error Message"
%>

Now adjust the three variables in the feed:

http://myfeed.xml
This is replaced with the URL of your feed. Just highlight and paste away!
MyXSLT.xslt
This is the call to the XSLT used to transform the feed into HTML.
Be sure to use a root-relative link!
My Error Message
JIC things go wrong you can have a custom error message display. Just about anything want too including a link or e-mail. Just be sure to change any quotes in your HTML message to single quotes so it doesn’t conflict with the quotes the JavaScript is using.
So this:

 <a href="mailto:jeff@umn.edu">

Becomes this:

<a href='mailto:jeff@umn.edu'>

3. The Feed and XSLT

I am not going to lie to you, this gets tricky! An RSS feed is just raw XML, something needs to transform it so it will display in some intentional way on a Web page.

Here are three examples based on a feed from the CEHD events calendar. You can download the XSLT and CSS and mess around with each sample. There are lots of comments in the XSLT code to guide you along using this feed.

The Basic
This grabs the full date from the event and the title and wraps both in a paragraph tag. Very basic as the name implies.
The list
Same as basic but now it throw the items into a list, limits the number of events displayed to six and links the title back to the events calendar.
The table
Super uber-wicked! Builds a table and checks to see if there are multiple events for one date so the day does not keep repeating.

These are actually very basic examples, more fun can be found at W3 Schools tutorial on XSLT!