Documentation

ColdFusion Integration

Here is the code to use for Cold Fusion integration.

The following examples demonstrates server-side caching with KitGUI.

Here is the Adobe manual for cache related functions in CF9
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec1b05d-7fe0.html

This blog post is from one of the CF gurus Ray Camden
http://www.coldfusionjedi.com/index.cfm/2009/7/18/ColdFusion-9-and-Caching-Enhancements

<cfcomponent name = "KitGUI">
    
<!--- replace with your own KitGUI CMS Account Key --->
    <cfset variables.accountkey = "00000000000000000000000000000000">
    <cffunction name="getContent" returntype="string" access="public">
        <cfargument name="contentID" type="string" required="yes" hint="KITGUI Content ID">
        <cfargument name="contentType" type="string" required="yes" hint="KITGUI Content Type">
        <cfset var kitGuiURL = "http://s3.amazonaws.com/kitgui/clients/#variables.accountkey#/ids/#arguments.contentID#.txt">
        <cfset var editMode = structKeyExists(COOKIE,"kitgui") and COOKIE.kitgui eq 1>
        <cfset var raw = "">
        <cfif not reFind("^[a-zA-Z]+[a-zA-Z0-9\-_]*$",arguments.contentID)>
            <cfthrow message= 'KitGUI content ID must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_")'>
        </cfif>
        <cfset kitGuiURL = "http://s3.amazonaws.com/kitgui/clients/#variables.accountkey#/ids/#arguments.contentID#.txt">
        <cfif not editMode>
            <cfset raw = cacheGet("#arguments.contentID#")>
        </cfif>
       
<!--- invalidates cache if in edit mode --->
        <cfif editMode or not isDefined("raw")>            
            <cfhttp url="#kitGuiURL#" method="get"></cfhttp>
            <cfif not (cfhttp.errorDetail neq "" or cfhttp.statusCode contains "404")>            
                <cfset raw = cfhttp.filecontent>
               
<!--- cache for an hour --->
                <cfset cachePut("#arguments.contentID#", raw, createTimeSpan(0,1,0,0))>
            <cfelse>
                <cfset raw = "">
            </cfif>            
        </cfif>
        <cfif editMode>
            <cfreturn '<div style="display:inline-block" class="kitgui-id-#arguments.contentID# kitgui-content-type-#arguments.contentType#">' & raw & '</div>'>
        <cfelse>
            <cfreturn raw>
        </cfif>
    </cffunction>
</cfcomponent>

Here's how to call it on your output:

<cfoutput>
   
<!-- your HTML above -->
    <cfset variables.KitGUI = createObject("component","KitGUI")>
       #variables.KitGUI.getContent(contentID="your-content-id", contentType = "HTML")#
  
<!-- your HTML below -->
</cfoutput>

This gets more interesting when you set the content ID based on dynamic URLs. You can quickly setup infinte pages with a template this way. The KitGUI docs was setup this way very quickly. View the videos for more information.

Authored by Easwar Chandran (odesk handle "Easwar Chandran")