Steven Erat's Blog Steven Erat Photography
 
 
Viewing By Entry
 
 

TalkingTree  Yet Another Tag Pod for BlogCFC

 

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.

<cfsetting enablecfoutputonly=true>
<cfprocessingdirective pageencoding="utf-8">
<!---
   Name : tags.cfm
   Author : Steven Erat
   Created : November 15, 2005
   Last Updated : March 5, 2006
   History : Based on blog entries by Pete Freitag and Joe Rinehart
   Purpose       : Display archives as sized tags
--->


<cfmodule template="../../tags/podlayout.cfm" title="Tags">

   <cfset cats = application.blog.getCategories()>
   
   <cfquery dbtype="query" name="tags">
      SELECT entrycount AS tagCount,categoryname as tag, categoryid
      FROM
         cats
      WHERE entrycount >= 10
   </cfquery>
   
   <cfset tagValueArray = ListToArray(ValueList(tags.tagCount))>
   <cfset max = ArrayMax(tagValueArray)>
   <cfset min = ArrayMin(tagValueArray)>
   
   <cfset diff = max - min>
   <!---
      scaleFactor will affect the degree of difference between the different font sizes.
      if you have one really large category and many smaller categories, then set higher.
      if your category count does not vary too much try a lower number.      
   --->

   <cfset scaleFactor = 25>
   <cfset distribution = diff / scaleFactor>
   
   <!--- optionally add a range of colors in the CSS color property for each class --->
   <cfoutput>
      <style>
         .smallestTag { font-size: 9px; }
         .smallTag { font-size: 11px; }
         .mediumTag { font-size: 13px; }
         .largeTag { font-size: 16px; }
         .largestTag { font-size: 20px; }
      </style>
      
      
      <cfloop query="tags">
         <cfsilent>
            <cfif tags.tagCount EQ min>
               <cfset class="smallestTag">
            <cfelseif tags.tagCount EQ max>
               <cfset class="largestTag">
            <cfelseif tags.tagCount GT (min + (distribution*2))>
               <cfset class="largeTag">
            <cfelseif tags.tagCount GT (min + distribution)>
               <cfset class="mediumTag">
            <cfelse>
               <cfset class="smallTag">
            </cfif>
         </cfsilent>
         <a href="#application.rootURL#/index.cfm?mode=cat&catid=#tags.categoryid#"><span class="#class#">#lcase(tags.tag)#</span></a>
      </cfloop>
   </cfoutput>
   
   
</cfmodule>
   
<cfsetting enablecfoutputonly=false>

 


Comments

The provided code does not work. You need to move the CLASS out of the A tag to a SPAN tag, just like Steven does it in his blog.

~Rob


Fixed. Thank you.


any intention to port this pod to the new user friendly categories in blogcfc5 ?


I'm planning to reserve a weekend to migrate to BlogCFC sometime this summer, but until then I probably get to the tag cloud. Isn't the table structure similar enough to work as is? Or does the query need to be rewritten?


all it takes is to replace the link on the href to application.blog. makeCategoryLink(categoryid)


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
      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    

Search This Site

 
This is an exact search only

About This Site

 
Adobe Alumni & Community Professional. Expert in ColdFusion, Flex, LCDS, Photoshop, Lightroom. Linux RHCE. Follow Me!. For my photography check out Boston Portrait Photographer.
More about me

Recent Entries

 
ColdFusion 9.01 Server Monito..

Recent Comments

 
Posted By Swagat:
Ben Forta, best-selling ColdFusion author is coming to India this August at India's largest Adobe Flash Platform Conference. Ben Forta will conduct a ...

Posted By Steve:
The updated presentation I gave at CF.Objective() 2010 is available here: [link] At the end of the preso I gave a brief, pre-recorded demo of wri ...

Posted By Brad Munz:
I've come across a OOM problem in HotSpot which looks alot like this: java.lang.OutOfMemoryError: requested 4096000 bytes for GrET in /BUILD_AREA/jdk6 ...

recently played

 

no song is playing

now playing, a plug-in for itunes

Categories

 
RSS Adobe (34)
RSS Bicycling (9)
RSS Blogging (39)
RSS Books (13)
RSS Breeze (13)
RSS CFMX Podcasts (10)
RSS ColdFusion (429)
RSS Computer Technology (51)
RSS Events (26)
RSS Flex (20)
RSS Gadgets (10)
RSS HiTech Industry (16)
RSS Java (25)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (22)
RSS Macromedia (27)
RSS Meetup (35)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photos (111)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Twitter (10)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Terrence Ryan
Ben Forta
Ray Camden
Kinky Solutions
Dan Vega
Gary Gilbert
Simeon Bateman
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2010 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer