Inspired by Joe Rinehart and Pete Freitag, here's another version of a Tag Cloud Pod for BlogCFC, available as an attachment by clicking the Download link.

I found the use of a scaleFactor variable very helpful in trying obtain an even distribution of tag sizes for a widely varying tag count. See the pod's inline comments about scaleFactor. You can also adjust which tags qualify for the tag cloud by the WHERE clause of the query. In the example below, I only select categories having more 10 or more posts.

See the BlogCFC Pod Forum for how to install a pod.

view plain print about
1[cfsetting enablecfoutputonly=true>
2[cfprocessingdirective pageencoding="utf-8">
3<br/><br/>[cfmodule template="../../tags/podlayout.cfm" title="Tags"><br/><br/>    [cfset cats = application.blog.getCategories()>
4    
5    [cfquery dbtype="query" name="tags">
6        SELECT entrycount AS tagCount,categoryname as tag, categoryid
7        FROM
8            cats
9        WHERE entrycount >= 10
10    [/cfquery>
11    
12    [cfset tagValueArray = ListToArray(ValueList(tags.tagCount))>
13    [cfset max = ArrayMax(tagValueArray)>
14    [cfset min = ArrayMin(tagValueArray)>
15    
16    [cfset diff = max - min>
17    
18    [cfset scaleFactor = 25>
19    [cfset distribution = diff / scaleFactor>
20    
21    
22    [cfoutput>
23        <style>
24            .smallestTag { font-size: 9px; }
25            .smallTag { font-size: 11px; }
26            .mediumTag { font-size: 13px; }
27            .largeTag { font-size: 16px; }
28            .largestTag { font-size: 20px; }
29        </style>
30        
31        
32        [cfloop query="tags">
33            [cfsilent>
34                [cfif tags.tagCount EQ min>
35                    [cfset class="smallestTag">
36                [cfelseif tags.tagCount EQ max>
37                    [cfset class="largestTag">
38                [cfelseif tags.tagCount GT (min + (distribution*2))>
39                    [cfset class="largeTag">
40                [cfelseif tags.tagCount GT (min + distribution)>
41                    [cfset class="mediumTag">
42                [cfelse>
43                    [cfset class="smallTag">
44                [/cfif>
45            [/cfsilent>
46            <a href="#application.rootURL#/index.cfm?mode=cat&catid=#tags.categoryid#"><span class="#class#">#lcase(tags.tag)#</span></a>
47        [/cfloop>
48    [/cfoutput>
49    
50    
51[/cfmodule>
52    
53[cfsetting enablecfoutputonly=false>