blogging california england firefox glassfish google hacking j2ee java openid opensource roller skype soccer sun sunray tagging thewaronliquid travel treo ubuntu voip web2 work yahoo
Jan
8

OK, I just tidied up the tag cloud code a bit; there's now some scaling to ensure the 'intensity' is sensible. The template code relies on some styles which set the font size and opacity.

    <div class="tagcloud">
       #set ( $maxtags = 25)

       #set($mytags = $model.weblog.getPopularTags(-1, $maxtags))

       #set($maxtagcount = 0)
       #set($mintagcount = 99999)

       ## number of styles s1-s10
       #set($steps = 10)

       ## determine min and max tag count so we can scale the fonts and opacity
       #foreach ($tag in $mytags)
          #if($tag.count > $maxtagcount)
             #set($maxtagcount=$tag.count)
          #end 
          #if($tag.count < $mintagcount)
             #set($mintagcount=$tag.count)
          #end 
       #end

       ## generate the link for each tag assigning style accordinly
       ## the styles : s1-s10 increase in font size and opacity   
       #foreach ($tag in $mytags)
          #set ($intensity=(${tag.count}-${mintagcount})*${steps}/(${maxtagcount}-${mintagcount}))
          <a class="tag s${intensity}"  href="$url.tag($tag.name)" 
             title="$tag.count entries">$tag.name</a>
       #end
    </div>
     
Relevant fragments from the stylesheet follow, first I set the abolsute position of the tag cloud then  reduce the line-height for effect. Then I define s1-s10, increasing the font size and opacity proportionally. The opacity requires different hacks for different browsers and I still don't think I have all the IE versions covered. Sigh.
   div.tagcloud
   {
      line-height:18px;
      position: absolute; 
      text-align: right; 
      top: 90px; 
      right: 20px;   
      left: 600px; 
   }

   .s1 {
     font-size:18px;
     filter:alpha(opacity=20); 
     filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20);
     opacity:.2;
   }

Comments:

Post a Comment:

Comments are closed for this entry.

Find it

Subscribe

Contact Me

My status

follow pixelfodder at http://twitter.com

Links

The Aquarium (from the source)

Images

sharps. Get yours at flagrantdisregard.com/flickr