|
Converting Word Press Cumulus plugin to BlogCFC |
The other day I saw the Word Press Blog Cumulus plugin (http://wordpress.org/extend/plugins/wp-cumulus/) on a fellow bloggers site, and thought 'I like that, I wonder if it will work inside the Blog CFC framework'. I thought I'd convert it so that it would.
The Cumulus plugin uses the regular Blog category cloud and turns it into a three dimensional rotating globe. It does this using a flash object, and a series of parameters passed in as flashvars.
2 <div id="flashcontent">This will be shown to users with no Flash or Javascript.</div>
3
4 <s/cript type="text/javascript">
5 var so = new SWFObject("#application.rootURL#/includes/tagcloud.swf", "tagcloud", "170", "120", "7", "##ffffff");
6 // uncomment next line to enable transparency
7 //so.addParam("wmode", "transparent");
8 so.addVariable("tcolor", "0x3258B8");
9 so.addVariable("mode", "tags");
10 so.addVariable("distr", "true");
11 so.addVariable("tspeed", "100");
12 so.addVariable("tagcloud", "#variables.tagsList#");
13 so.write("flashcontent");
14 </s/cript>
You need to include the 'swobjects.js' reference call to process to swf, otherwise the 'flashcontent' div will be displayed.
The flashvars include the variable 'tagcloud', this controls which tags are displayed, what their colors are, and where the go (URL). These are generated in a cfsavecontent variable almost as a list.
2 <cfif tags.tagCount EQ min>
3 <cfset size="9">
4 <cfelseif tags.tagCount EQ max>
5 <cfset size="20">
6 <cfelseif tags.tagCount GT (min + (distribution*2))>
7 <cfset size="16">
8 <cfelseif tags.tagCount GT (min + distribution)>
9 <cfset size="13">
10 <cfelse>
11 <cfset size="11">
12 </cfif><a href='#application.rootURL#/index.cfm?mode=cat%26catid=#tags.categoryid#' style='#size#' <cfif len(variables.color)> color='0x#variables.color#' </cfif> <cfif len(variables.hicolor)> hicolor='0x#variables.hicolor#' </cfif> >#lcase(tags.tag)#</a></cfloop></tags></cfsavecontent>
The swf will control the color of the Tags based on their sizing, or you can specify a 'color' and a 'hicolor', which are the regular color and the highlight color respectively. I have placed the swfobject.js and the tagcloud.swf in my site/includes/ directory, but you can put it where you want, just edit the links.
You can download the code from RIA forge here: Link
Thanks to Roy Tanck for the documentation on how the Cumulus plugin works:
http://www.roytanck.com/2008/05/19/how-to-repurpose-my-tag-cloud-flash-movie/