Syndicating Wharton Feeds

by Hella ~ August 25th, 2004

As part of an upcoming project, I’ve written a piece of code to allow anyone to place Wharton news feeds on any webpage. All it takes is a bit of simple JavaScript and perhaps some HTML tidying if you’re particular about how things appear. To put it on your page, follow these simple instructions.

Copy and paste this bit of JavaScript into your HTML template where you want the information to appear.

<ul>
<script language="JavaScript" type="" src="http://mba.wharton.upenn.edu/mba/rss/feed/s2s_js.php">
</script>
<script language="JavaScript" type="">
for (i = 0; i < s2s_links.length; i++) {
document.writeln ("<li><a href=\"" + s2s_links[i].link + "\">" + s2s_links[i].title + "</a>");
}
</script>
</ul>

The code for the Diaries is similar.

<ul>
<script language="JavaScript" type="" src="http://mba.wharton.upenn.edu/mba/rss/feed/diaries_js.php">
</script>
<script language="JavaScript" type="">
for (i = 0; i < diaries_links.length; i++) {
document.writeln ("<li><a href=\"" + diaries_links[i].link + "\">" + diaries_links[i].title + "</a><br/>- " + diaries_links[i].diarist + "</li>");
}
</script>
</ul>

Note that this code places each link inside an <li> tag. Be sure you’re putting the whole thing inside a set of <ul> tags or just remove the <li> completely.

Now if you want to get fancy and see what variables are in the JavaScript, you can always pull up the link itself and check out the underlying array.

There are similar bits of code that accomplish the same thing but I needed a custom solution for aggregating several feeds together. Code such as Feed2JS works if you’ve got just one feed, but I wanted to combine many feeds, order the articles by publish date, and produce the output, much like on my Aggregated News pages.

If you have questions, contact me: hella at opencoder dot org

Comments are closed.