MovableBlog: Archives: November 2004

A weblog about the Movable Type Publishing Platform and other geekery

November 30th, 2004

Related Links in Your Sidebar Using RSS, PHP and Magpie », for me, is not so much a way to store my bookmarks online and view others' bookmarks as it is a collaborative linkblogging tool. In this article, I detail how I created a "related links" sidebar on my personal weblog, Just a Gwai Lo (scroll down to the "Delicious" heading; the same script is used to generate a less-cluttered page of links). Here is, in brief, how it works: I make a link at, tag it—generally looking at the HTML pages of the tags I'm using, to see what I'm getting myself into—and then use the RSS feeds generated for each tag to add on a few links as, essentially, related links. If Flickr had tags inside a <dc:subject> element like did, I'd be spending the time writing this article making basically the same thing, except a "related photos" page. I suppose I could learn the APIs for both and Flickr and accomplish the same thing, but I'd rather not.

The first two lines of the script enable the RSS fetching functions from the Magpie RSS library. The line after that starts an unordered list for the links. If you'd rather skip reading the explanation in this article, you can view the source code. One day I'll put this code in my Subversion repository, which gently weeps because it is currently empty.

I should mention that the source code is the most current version of the script, and may differ slightly from what you read below.

You need the Magpie PHP RSS library. Also make sure to make the changes noted in the script itself.

require_once "/home/richard/rssclasses/";
require_once "/home/richard/rssclasses/";

print "<ul>\n";

The third line tells the rest of the script what your username is:

$username = "username"; // replace with your username

When I was testing the script, was down for a few minutes, and I needed the ability to say the links were "unavailable at the moment". The Magpie Cookbook gives a method for cloaking warnings, so I included the following line before Magpie fetched the RSS feed.

error_reporting(E_ERROR); // cloak error messages

The next line fetches the RSS feed and puts the items into an an object.

$del = fetch_rss("".$username);

The next line simply checks to see whether the fetch was successful:

if ($del) {

Since shows the last 30 links that you've posted, it can get a little out of hand when you have related links on top of that, so I limit the amount of links to 5. You can experiment with the number to get the amount you're commfortable displaying.

$delitems = array_slice($del->items, 0, 5);

Starting the loop to display the items from the RSS feed:

foreach ($delitems as $item) {

The next line and following if block check to see if the date has been printed yet. If you want a different date format than, for example, "November 21st, 2004", check the PHP date codes and replace "F jS, Y" accordingly.

   $datethis = date("F jS, Y", parse_w3cdtf($item['dc']['date']));    
if ($datethis != $dateprinted) {
print " <li>";
print $datethis;
print "</li>\n";

Now comes the code to display your link and the description, if there is one. I like having lots of print statements because it makes debugging easier.

   print "  <li>";
print "<a href=\"";
print $item['link'];
print "\">";
print $item['title'];
print "</a>";
if ($item['description'] != "") {
print ": ";
print $item['description'];
print "</li>\n";

Now the fun part. The next if statement checks to see if there is a <dc:subject> element inside the item that the script is processing, which means you have tagged the link with one or more tags.

   if (isset($item['dc']['subject'])) {

If there are tags, then the script converts the string separated by spaces into an array.

     $tags = explode(" ", $item['dc']['subject']);

Now the script creates another list item in HTML, then starts a nested list within that list item.

     print "  <li>\n";
print " <ul>\n";

After starting the nested list, the script fetches the RSS feed for each of the tags in the item. The third line in thiis code block limits the related items to 2, because otherwise, if you tag your item with a lot of tags, you'll get a lot of related items.

     foreach ($tags as $tag) {
$tagrss = fetch_rss("".$tag);
$tagitems = array_slice($tagrss->items, 0, 2);

Still only processing the RSS feed of one of your tags, another loop starts to process the items in that RSS feed. The second line filters out links created by you (after all, those links appear in the RSS feed for the tag as well) because it would just be redundant, especially if the last few links with that tag were your links.

       foreach ($tagitems as $tagitem) {
if ($tagitem['dc']['creator'] != $username) {
print " <li>";
print "<a href=\"";
print $tagitem['link'];
print "\">";
print $tagitem['title'];
print "</a>";

We're still in the second loop (that is, inside the loop for the tag's RSS feed which is inside the loop for processing the tags of your original item), and the following block...

           if (rtrim($tagitem['description']) != "") {
print ": ";
print $tagitem['description'];

Because you were not the original author of the related link--unless you have another account that you linked something using the same tag with--you can absolve yourself of some responsibility of the content (link URL, text and description) by saying who it was linked by. In this script, I had it so that it linked to the author's page. (It seemed only fair that if I'm syndicating their content I should link to the page from which it came.) After doing this, all the loops, except for the very first, which is of your links' RSS feed, are closed, as is the nested list.

           print " (linked by ";
print "<a href=\"";
print $tagitem['dc']['creator'];
print "\">";
print $tagitem['dc']['creator'];
print "</a>)</li>\n";
print " </ul>\n";
print " </li>\n";

The next line stores the date of the most recent item printed, so that when it goes back to the top of the loop, it can check against the date of the next item. The original loop is closed (after all of your items are processed) and the if block is closed.

   $dateprinted = $datethis;

Remember how we had the rudimentary error checking at the beginning? The following else block just prints something more friendly than an ungly error message. Lastly, the end tag for the unordered list is printed.

else {
print "<li> links not available at the moment.</li>\n";

print "</ul>";

That's the script. Let me know if you run into any problems with it. I've been meaning to update my instructions to integrate PHP and using Magpie and my instructions to integrate using a Movable Type plugin, but instead wrote the above script.

Posted by Richard at 11:01 PM | Category: PHP

November 24th, 2004

Letters From Home »

The chances of my doing a podcast, which, as I understand it, is posting audio of people talking, are pretty slim. I've listened to a few podcasts, and finished listening to only a handful of those. As a podcast consumer and producer, then, I admit to not really understanding the big deal, but then again, I don't really get the big deal about talk shows in general. That's what podcasts are, and that's fine. Lots of people like talk shows, but I'm not a big fan.

As a cultural phenomenon, then, I think I get it, and it's a big deal, because for the price of a computer, a microphone, and an Internet connection, anybody who wants a talk show can have one. That's a lot less than having to ask for a broadcast license (are the days of podcasting licenses near?), setting up a radio station, and so on. The interesting part about podcasting is you don't really need a "pod" (or personal audio player) to listen in. As long as you have a computer with audio (who doesn't?) and an audio player, then you can consume podcasts. You could almost say that pods don't belong in podcasting. 10 points if you got the movie reference.

I am most excited not about people having their own talk shows, but people using podcasting to talk to their friends and family, using them as "letters from home". That phrase comes to me from DJ Shadow's "Letter From Home (Track 1)" and DJ Shadow's "Letter From Home (Track 14)", the first and last tracks of his excellent album The Private Press. (His first album, Endtroducing.... which combined thousands of samples to create an instrumental hip-hop album, is far and away my favourite of all time.) In both the "Letter From Home" tracks, DJ Shadow plays some found art, recordings people have made of themselves speaking to their family members and other assorted loved ones. The first one is a woman talking about how she had difficulty setting up her recorder and how her trip went, and the second is from a man talking about how hot it is and a woman talking about her vacation and plans to return.

I was once instant messaging with a friend whose phone number I didn't have, and felt silly asking for it, since we talked most of the time via IM anyway. She had audioblogged at one point, possibly about a rant she had, I forget. I called up the weblog entry that she posted her audioblog to, and just listened. Not for content, but to hear her voice. Blogging is great—no, really—but it's not really the unedited voice of an individual, at least not literally. Podcasting is the real unedited voice of an individual. It's terribly exciting to hear the voices of people whom I mostly know through print. I'm sure this will wear off, but it's exciting to hear the famous-to-me people speak in my living room, such as my living room is.

In the longer run, voice over IP is probably a bigger deal than podcasting, because with voice over IP, you can at least have a conversation. But podcasting is revolutionary in that, just as blogging did, it lengthens the tail. In other words, the big deal is no longer that some people can do it, but that pretty much everybody can. As a non-consumer non-producer of podcasts, I can at least appreciate them for that.

Posted by Richard at 07:00 PM | Category: Geekery

November 20th, 2004

My Name in Print »

Rogers Cadenhead is someone I've had respect for as a writer on RSS, Java, and especially—though I used the software all of twice—Radio Userland. In March of this year, he asked my permission to publish a screenshot of the Trackback listing of my review of the TypePad hosted blogging service in his then-forthcoming book on Movable Type. I agreed, being honoured just for having been asked. This month, his book Movable Type 3 Bible, Desktop Edition hit the stores. While in Portland, Oregon, visiting friends, I stopped by the Powell's Technical Bookstore and asked if they had a copy (but not before looking for it myself). When presented with the copy, looking at the section for Trackback, and seeing myself and my website referred to in print—for the first time, my knowledge—over two pages no less, the purchase decision was an easy one.

The following are the relevant paragraphs:

Figure 11-1 shows how trackback links are presented in MovableBlog, a weblog by Richard Eriksson ( His site is devoted to poking around Movable Type, and when he wrote an entry reviewing Six Apart's TypePad hosting service, his review was discussed on six other weblogs. These weblogs sent trackback messages to Eriksson's server that were received by Movable Type and saved to his weblog's database.

As a means of receiving feedback on your work, trackback is comparable to receiving comments in response to an entry— but in this case the comments are hosted on someone else's weblog. On MovableBlog, Eriksson presents trackback links on the same page as comments, enabling his visitors to see the kind of feedback each of his entries has received. Mena and Ben Trott, inventors of the protocol, call it a form of remote commenting.

Figure 11-1 in the book is the screenshot mentioned above of the Trackbacks section of a weblog entry on my site. Astute readers of the book will compare the above paragraph and note that in the book, my family name is misspelled twice (though it is initially spelled correctly, and it is spelled correctly in the acknowledgments), so I took the liberty of correcting it as well as referring to my weblog by its current name. Rogers correctly capitalized the name of it in his book, but I since changed it.

If I weren't trying to read a half-dozen books at the moment, I'd be able to properly review Rogers' book. I've only been able to read and re-read the paragraphs that mention my name, but flipping through the book, Rogers has done a thorough job of covering all the elements of the Movable Type CMS. It covers installing Movable Type, creating a weblog entry, enabling, accepting and moderating comments (and, of course, Trackback), creating and maintaining templates, and more advanced topics like RSS feeds and the Atom API.

Posted by Richard at 01:38 PM | Category: MT

November 16th, 2004

Search Engine Optimization Gets You Accessibility For Free, and Vice Versa »

Trenton Moss writes an excellent short article on search engine optimization and usability, two subjects which go hand in hand, because the more usable your site is, and the higher the quality of information the site is, the more likely people are going to come for return, paying visits:

By providing creative, unique and regularly updated content on your Website, other Webmasters will want to link to your site: doing so will provide extra value to their site visitors. Of course, you'll also be adding value for your site visitors.

I like the emphasis placed on making a site structured and and accessibility. He's implying that if you make a site accessible, you get search engine optimization for free, and if you make a site search engine optimized, you get accessibility for free.

(I credit the phrase "you get [x] for free" as well as the idea that accessibility and search engine optimization are two sides of the same coin&mdash;as if "hand in hand" wasn't enough of a metaphor for you&mdash;to Boris Mann.)

Posted by Richard at 12:30 AM | Category: Geekery

November 4th, 2004

In the Future, Domains and URLs Won't Matter »

Darren Barefoot writes some excellent advice on choosing a domain name. (I work for Bryght, a company he mentions as an example of having a bad domain name.) A common joke amongst geeks when a new phrase invented—sometimes by the leader of a certain very powerful, English-speaking country, the current example being Rumors on the Internets—the first thought is to register the domain. That way, when the appropriate time comes, you can put up a website mocking said new phrase (in the case of "Rumors on the Internets", by simply looping video of the aforementioned leader saying the phrase—which used to be the case, at least), and hey, maybe you might even register the domain first before realizing that you can somehow profit from it, or at least start a company around it.

Registering a domain, though, will become less important a) when that domain has already been registered (somebody beat me to by a couple of days) and b) when all that matters is not what people type in the address box but what people type in a search box for the search engine du jour, that title held currently by Google. With Firefox for all platforms and Safari for the Mac coming with a Google text box as the default web search text box, Google because the default search engine, just as Netscape, being the home page of the Netscape Navigator browser, became the default starting point for the web for most people. The default search engine for many is MSN now that Internet Explorer is deployed on the vast majority of computers.

As Darren pointed out earlier, the home page will no longer be the most important page on a person or company's website, though the manifesto he links to does not adequately state why this is the case. The reason the home page is not the most important page is because most visitors will be coming into your site via search engine requests, and as is the nature of users on the Internet, expect unexpected search terms for people landing on your site. (That is, if Disturbing Search Requests—a site that is text-based but is not necessarily safe for a sex-free environment—is any guide.) Because most visitors will be seeking you out rather than be led to your site by any clever advertising you have devised, high search engine ranking (i.e. on the first page of results on the default setting for the number of results a search engine gives, either because what they're looking for is on the first page or they are too impatient to click "next") for the key words of your core business—or even a business that you would like to expand into—is priority #1, and not purchasing that thousand-dollar domain name that some kid is squatting on.

I say that this is the future and not the present, because short, descriptive URLs are important now for the following reasons:

When users—if you are reading this weblog, the odds are that you are a techie and while I salute you, you are not in the majority—look for something, they either type the text that they are searching for in the address box or go to Google and type in what they are looking for. People are much less likely to remember what URL they found something than the search terms they used to find it.

Posted by Richard at 04:40 AM | Category: Geekery