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

This blog post is from one of the CF gurus Ray Camden

<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 = "">
        <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 ("_")'>
        <cfset kitGuiURL = "">
        <cfif not editMode>
            <cfset raw = cacheGet("#arguments.contentID#")>
<!--- 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))>
                <cfset raw = "">
        <cfif editMode>
            <cfreturn '<div style="display:inline-block" class="kitgui-id-#arguments.contentID# kitgui-content-type-#arguments.contentType#">' & raw & '</div>'>
            <cfreturn raw>

Here's how to call it on your output:

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

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")