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.
- 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=https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
The 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 - In Blog.cfc in org/camden/blog add the following to (around) line 101. It should be obvious where its going
- 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/
- Around line 91 the variable "keylist" is set. Add to the end "jqueryLocation"
- Find in the form where the "blogurl" is set and underneath add the following
jQuery Location: - 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