Wednesday Jun 27, 2007

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($tag.name)"
            title="$tag.count">$tag.name</a>
    #end
#end 

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 {
   font-size:60%;
   }
   .s2 {
   font-size:80%;
   }
   .s3 {
   font-size:100%;
   }
   .s4 {
   font-size:120%;
   }
   .s5 {
   font-size:140%;
   }
</style>

That's all there is to it. I can link to all entries for a given tag - for example, http://blogs.sun.com/superpat/tags/opensso; there are even RSS feeds per tag - http://blogs.sun.com/superpat/feed/entries/atom?tags=opensso. You can also combine tags to get an intersection - http://blogs.sun.com/superpat/tags/opensso+saml. I've completely moved from categories to tags now - "It just works".

Monday Jan 08, 2007

From Categories to Tags

I finally got round to completing Superpatterns' migration from categories (exactly one category per post) to tags (zero or more tags per post). You can see the tag cloud at the top of the page (if you're reading this through syndication you'll have to visit my actual web page to see this). The size of each tag name in the tag cloud relates to the number of blog entries with that tag. If you still want to navigate by categories, they are listed in the dropdown near the top of the column on the right.

Thanks to Rich Sharples for the category chooser tip and to Dave Levy for the tag cloud idea.

About

superpat

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today