Generating an accessible tag cloud with drupal

A couple of months ago I found myself needing to generate a “tag cloud” in drupal. The contents of the cloud would be all the children categories of a container and as is the norm with tag clouds it needed to display those children at varying sizes based on how popular they are. I looked around at the existing options but none fitted my requirements in how they integrated with the category module, or producing semantically helpful html.

So I rolled my own. It’s a quick module that just provides a few simple utilities. The cloud is initially generated as an unordered list, with the number of nodes matching each tag included in brackets, eg:

There’s then a jquery function, called on document load, that works through the list, hides the content in the brackets, and changes the size of the text based on the tag’s popularity.

You can include it in a page by calling:

within your theme. I’ve tested the module against drupal 4.7 but it should work fine in 5.x (and I guess 6.x).

I don’t have time or the inclination to do much more work with this module, or to provide support for it, but it seemed worth throwing out there in case anyone else wants to build on it. If you’d like to adopt it, let me know and we can collaborate.

If you’re interested, you can get the tarball here.

Tags: , , ,

Comments are closed.