ColdFusion Keyword Maker CFC
Code March 29th, 2007
I whipped up a quick ColdFusion Component to take small lists of keywords and make very large lists of keywords. This is great for you SEO guys out there that like targeting the long tail key phrases.
You need to pass it in a list of keywords (or phrases) and a list of “mix-in” words that it can use to build new phrases. It will default to a maximum of 5 word long phrases but you can override that by passing in another number.
<cfcomponent output="no"> <cffunction name="init" access="public" returntype="string"> <cfargument name="Keys" type="string" required="yes"> <cfargument name="MixerList" type="string" required="yes"> <cfargument name="NumberToGen" type="numeric" required="yes"> <cfargument name="MaxWordsInKey" default="5" required="yes" type="numeric"> <cfset var NewKeys = ""> <cfscript> //we want to use the original list first then mix new words in origLen = Listlen(arguments.keys); numToMix = 1; //start with one mix word then we will add more and more as needed maxToMix = arguments.MaxWordsInKey; //this will tell the script how many mix words to use max. afterwards it will start splitting up the original words counter = 1; //start the counter for iterations listPos = 1; for(i = 1; i LTE arguments.NumberToGen; i = i + 1) { useKey = ListGetAt(Keys,listPos); MixedKey = MixKey(numToMix,arguments.MixerList,useKey); if (NOT ListFindNoCase(NewKeys,MixedKey)){ NewKeys = ListAppend(NewKeys,MixedKey); counter = counter + 1; } //end of the list? if (listPos EQ origLen){ listPos = 1; //start again at the beginning if (numToMix LT maxToMix){ numToMix = numToMix + 1; } } listpos = listpos + 1; } </cfscript> <cfreturn NewKeys> </cffunction> <!--- this method will get all keywords in a given category ---> <cffunction name="MixKey" returntype="string"> <cfargument name="Mixers" type="numeric" default="1" required="yes"> <cfargument name="MixList" required="yes" type="string"> <cfargument name="keyToMix" required="yes"> <cfargument name="SplitKeys" required="no" default="0"> <cfset var Append = RandRange(0,1)> <cfset var MixIn = ""> <cfloop from="1" to="#arguments.mixers#" index="x"> <cfset MixIn = MixIn & ' ' & ListGetAt(arguments.mixList,RandRange(1,ListLen(arguments.mixList)))> </cfloop> <cfif Append> <cfset returnThis = MixIn & ' ' & arguments.keyToMix > <cfelse> <cfset returnThis = arguments.keyToMix & ' ' & MixIn> </cfif> <!--- trim just in case ---> <cfset ReturnThis = TRIM(returnThis)> <cfreturn returnThis> </cffunction> </cfcomponent>
Enjoy.
Leave a Reply
You must be logged in to post a comment.