December 14, 2003

Presently listening to:

Posted at 06:10 AM Gems, Notebook

This is a tutorial for installing a Windows-only implementation for Moveable Type (MT) bloggers, though Mac users may nonetheless find some useful ideas here, as certainly will enthusiasts for other blogging systems..

If you want to be able to insert Amazon links to whatever's playing on Windows Media Player or WinAmp into your blog entries, read on. It's not all that difficult: it does require some trival edits to some of your MT templates, and you'll have to install a couple plug-ins. If you don't already use Zempt 0.3 SharpMT 2.0 or w.Bloggar, you'll need one of these too, if only to generate the required code.

Caveat 1: if your blog is very big, this will likely slow your site builds considerably.

Caveat 2: you'll need to think of every entry in your blog, past and future, as code after implementing this. Because of that, it may not be appropriate or safe for all blogs

OK, so one of the cool things Zempt 0.3 is able to do is grab the 411 on whatever's playing on your WIndows MediaPlayer (or WinAmp), format it and paste the result to your cursor position in the edit window. Easy enough. And here's Zempt's default result:

[Listening to: Rhiannon - Fleetwood Mac - Rumours (04:11)]
What makes this subtly powerful is that the format is user-definable. Hmmmm.

That's what got me thinking...why not define a format that will apply the MTAmazon plugin to the data and generate something a bit more interesting? EG:

Presently listening to:
Regarding Saturday - Sumack - Now Hear This (03:38)

That is, munge the format so it generates the necessary plugin code and plops it into your edit window. Turns out that's easy enough too, but we're getting ahead of ourselves. So, the steps from the beginning.
Install the MTAmazon plugin as per the instructions here.
This plug-in allows MT to get images and links from Amazon via xml.

Install the Process Tags plug-in.
MT doesn't process any plug-in tags appearing in your entries. Using the Process Tags plug-in, we're going to force it to.

Replace all occurrences of '$MTEntryBody$' or 'MTEntryBody' in your templates with 'MTEntryBody process_tags="1"'
The templates you need to edit in the default MT implementation are: the Main Index (index.html), the Category Archive, the Date-Based Archive and the Individual Entry Archive. This will force MT to process all MT and plug-in tags appearing in your blog entries every time it rebuilds the site. Note that since your entries typically appear on multiple pages, this could slow your site rebuilds considerably if it's a very big site.

Caveat 2 also comes into play here. With the process tags plugin enabled you'll now have to think of all entries on your blog as code. In a sense, your entries are now MT templates.
Adam Kalsey, plugin author
Using [the process tags plugin] can be dangerous if you don't think about what you are doing. For example, if you have the PerlScript plugin installed, any blog author could execute arbitrary Perl code on your server. Another example would be putting an MTEntries block inside your entry. When MT rebuilt, it would find the MTEntries block in the entry, and load all those entries. One of the entries that it would load would be itself, again causing MT to find the MTEntries block, and so on, creating an infinite loop.
I can tell you from personal experience, that last scenario is unpleasant and likely to upset your ISP and the people you're sharing your server with. It makes me nervous just having the MTEntryBody text in this post. You can read all about it in the plugin forum at

Comments, which of course any visitor to your site can write, are safe because in this implementation they are not processed by the plugin. Don't extend the process tags plugin to MT comments -- that would be very bad.

Install Zempt, w.Bloggar or SharpMT, if you haven't already.
Eventually I'll implement a means for doing this without a special editor, but for now this is how we'll generate the MTAmazon plug-in code.

Start Zempt, w.Bloggar or SharpMT.
In Zempt, open Tools->Preferences from the menu and click on "Music" in the selection list on the left of the dialogue window. With w.Bloggar it's File->Settings, then click on the "Media" tab. For SharpMT, select Tools->Options then click the "Editor" tab.

There are two things to do here. First, make sure you've got the proper MediaPlayer or WinAmp software installed. There are links in the Zempt and w.Bloggar dialog windows if you don't. Second, replace the current contents of the media formatting string edit box with the following code.
<div class="media" align="right">
<MTAmazon search="%A% %B%" line="music" lastn="1"> 
        <a href="
        <MTAmazonASIN>/<MTAmazonAssociateID>" target="_blank">
            <img src="<MTAmazonMediumImage>" hspace="4" align="right" 
        <a href="">
            Presently listening to:</a>
        </i></strong><br /> %T% - %A% - %B% (%D%)<br /><br />
        <MTAmazonArtist><br />
        <a href="
        <MTAmazonASIN>/<MTAmazonAssociateID>" target="_blank">
            <MTAmazonTitle></a><br />
        <MTAmazonReleaseDate format="%B %e, %Y">
</div><br clear="right" />
You'll need to remove the formatting, so the whole bit is a single line of text.The %X% stuff is where Zempt and w.Bloggar are going to put the song Title, Artist name, alBum title and song Duration. If you're working with SharpMT, then you need to do some substitution:

  • %T% to [SONG]
  • %A% to [ARTIST]
  • %B% to [ALBUM]
  • %D% to [DURATION]

To make your life a little easier I've placed a couple versions of this code, both formatted and unformatted, in MediaInfoString.txt, which you can open in a non-word-wrapped text editor.

You might just want to look at your music library in Media Player or WinAmp and make sure all those titles and names are correct, or you'll get some unusual results from Amazon's search.

OK. Recheck your steps and you're ready to go.

Place your cursor where you want the Presently listening to: code to go, and click on the little musical notes button, wherever it is on your particular editor. Voila!

Now, you can either continue editing, or copy and paste the code to whatever other editor you prefer.

Happy musical bloggin!


Presently listening to:
Biko - Peter Gabriel - Shaking The Tree (06:53)

Posted by Patrick at December 14, 2003 06:10 AM
track backing
Excerpt: Another trackback test Presently Listening to...
Weblog: NoMad MaN
Tracked: December 26, 2003 02:13 PM