Blog Bling – Part 2 – Tag Cloud

Back in version 3.1, Apache Roller added support for tags. After Dave Levy blogged about tag clouds, I added one, based on his code:

#set($mytags = $model.weblog.getPopularTags(-1, 100))
#foreach ($tag in $mytags)
#if ($tag.count > 2)
<a class="tag s${tag.intensity}" href="$url.tag($"

The code is quite simple – we create a set of popular tags, and, for each tag, if there are more than two blog entries with that tag, we create a link. The link’s class is s1, s2…s5 based on the number of entries with that tag (‘tag intensity’). The classes control the font size of the link:

<style type="text/css">
.s1 {
.s2 {
.s3 {
.s4 {
.s5 {

That’s all there is to it. I can link to all entries for a given tag – for example,; there are even RSS feeds per tag – You can also combine tags to get an intersection – I’ve completely moved from categories to tags now – “It just works”.

One Reply to “Blog Bling – Part 2 – Tag Cloud”

Leave a Reply

Your email address will not be published.