The Pug Automatic

Scrobbler ( sidebar module

Written August 20, 2006. Tagged PHP, WordPress.

I recently switched this blog to the K2 WordPress theme. By the time you read this, I might be using something else – the blog is new and its appearance very much in flux.

K2 supports sidebar modules, similar to sidebar widgets.

I created such a sidebar module for use with the Scrobbler plug-in, which displays data in your blog.

Though there's nothing non-obvious about the code, it still might save someone else some work.

The module displays the favicon to the right of the header, similar to the RSS icon in some other modules. It achieves this by leveraging the feedlink CSS class. If you're anal about semantic HTML, you might want to rework this.

Watch it in action (at the time of writing, at least) at my "About" page.

This goes into a file like wp-content/themes/k2/modules/lastfm.php (download):


function lastfm_sidebar_module($args) {
global $scrobbler_user;

if ( function_exists('get_scrobbler') ) {
echo $before_module . $before_title . $title . $after_title;

<span class="metalink"><a href="<?php echo $scrobbler_user; ?>" class="feedlink" title="My profile"><img src="" alt="" /></a></span>

echo $after_module;

register_sidebar_module(' module', 'lastfm_sidebar_module', 'sb-lastfm');