Changing the jQuery location for BlogCFC

Another title for this post could be adding a property to BlogCFC. Basically I wanted to leverage Googles ajax APIrather than use a local version of the jQuery library. There are a couple of reason for this such as distributed CDN delivery, better caching on the users machine etc,actually you might want to read this postto understand why you would want to do this at all.

Back to adding a property.

  1. We're going to edit the blog.ini.cfm (settings) file in org/camden/blog and add the following
    #jQueryLocation=http://{Your Blog URL}/includes/jquery.min.jsjqueryLocation= first line is there for redundancy incase you need to test something locally or you are on a closed system with no web access. The second lineis what we are insterested in for this post and points to Googles Ajax Library
  2. In Blog.cfc in org/camden/blog add the following to (around) line 101. It should be obvious where its going
  3. Finally in your Layout.cfm under tags/ change:

    to the following

At this point we are pretty much done in terms of getting done what we set out to do. The following bit of code adds the new setting to the admin pagesso we can edit this in the future. What I explain next will add the jQuery location field to the settings.cfm in admin/

  1. Around line 91 the variable "keylist" is set. Add to the end "jqueryLocation"
  2. Find in the form where the "blogurl" is set and underneath add the followingjQuery Location:
  3. The final part is the validation rule. All I am doing is checking the value given is a valid URL. You could expand on this but for my purposesthis will do just fine. Look for <cfif structKeyExists(form, "save")> which is the start of the validation, go down a few lines and among the otherrules add
Thats it, you're done now. Going to your settings and updating them will remove the commented out line we added in point one earlier but with a methodto easily edit the location this shouldn't be a problem now