Skip to main content
Participant
September 18, 2008
Answered

Word/Tag Cloud widget

  • September 18, 2008
  • 2 replies
  • 608 views
Hi there,

I'm looking for a CF8 module/widget to produce a user-viewable word cloudd from a list of tags and/or document words, like what is found at http://www.tagcrowd.com/. I looked in RIA Forge but did't find this.

Is there a Web 2.0 wizard who's got this done?!

Thanks!

~Lance
(202) 470-6353
    This topic has been closed for replies.
    Correct answer Lance_A__Simon
    Nice! Thanks much, ~Lance

    2 replies

    Inspiring
    September 18, 2008
    Hi,
    raw example below:

    cheers, fober

    <cfparam name="text" default="This is a test for test purposes.">

    <cfoutput>
    <form method="post">
    <textarea name="text" rows="20" cols="60">#text#</textarea><br>
    <input type="Submit" name="submit" value="Generate!">
    </form>
    </cfoutput>

    <cfif text is "">
    <cfabort>
    </cfif>

    <cfset words= StructNew()>

    <cfoutput>
    <cfloop list="#text#" index="word" delimiters=" .">
    <cfif not listfind("& to of from for the at he she it a is in and or", word, " ")>
    <cfif StructKeyExists(words, "#word#")>
    <cfset count= StructFind(words, "#word#")>
    <cfset x= StructUpdate(words, "#word#", "#count+1#")>
    <cfelse>
    <cfset x= StructInsert(words, "#word#", "1")>
    </cfif>
    </cfif>
    </cfloop>

    <!--- <cfdump var="#words#" expand="No"> --->

    <div style="width:100%; border: 1px solid green;">TEST</div>

    <div style="width:100%; border: 1px solid blue;">
    <cfloop collection="#words#" item="word">
    <cfif StructFind(words, "#word#") GT 2>
    <cfset size= 10 + StructFind(words, "#word#")*2>
    <div style="border: 1px solid red; display: inline; font-size: #size#px"> #word# </div>
    </cfif>
    </cfloop>
    </div>
    </cfoutput>

    Participant
    September 19, 2008
    Really nice, and much appreciated. You folks are great!

    ~Lance
    Participant
    September 18, 2008
    Hi Lance,

    Here is a code snippet where "count" on the second line is the number of occurrences of the word or category that you are putting in the tag cloud. The font size is a variable that has a min and max size. Hope this helps.

    David
    Lance_A__SimonAuthorCorrect answer
    Participant
    September 18, 2008
    Nice! Thanks much, ~Lance