DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

My ColdFusion Tagging Engine/Library

03.15.2006
| 3621 views |
  • submit to reddit
        //via:http://www.whatspop.com/blog/2005/12/my-coldfusion-tagging-enginelibrary.cfm

<cfset tags_list = " CaMELCaSE comma, 'singlequoted' <b>bold</b> ""doublequoted"" double double this should be over the limit now " />
<cfset amount = 10 />
<cfset length = 20 />
<cfset tags_list = trim(tags_list) />
<cfset tags_list = lcase(tags_list) />
<cfset tags_struct = structnew() />
<cfloop index="tag" list="#tags_list#" delimiters=" ">
<cfset tags_struct[tag] = "" />
</cfloop>
<cfset tags_list = structkeylist(tags_struct," ") />
<cfset tags_list = listsort(tags_list, "textnocase", "asc", " ") />
<cfif tags_list neq "">
<cfif listlen(tags_list," ") lte amount>
<cfset amount = listlen(tags_list," ") />
</cfif>
<cfloop from="1" to="#amount#" index="tag">
/* Perform a database upload here */
<cfoutput>#htmleditformat(left(listgetat(tags_list,tag," "),length))#</cfoutput>
</cfloop>
<cfelse>
Sorry, you need to provide at least one tag
</cfif>