I started using BlogCFC long before I knew a whole lot about using CFCs as objects. When I first set up my blog, boyzoid.com, I had added a lot of custom methods directly to blog.cfc. While this allowed me to add some personal touches to the blog, I kind of painted myself into a corner. Whenever Ray released an update to BogCFC, if blog.cfc was affected, I would have to recreate my custom methods. After a while, it became to much of a hassle, and I just stopped updating the blog (I think I am still running version 3.something)

I decided, since I am contributing to the project, that I should probably update to BlogCFC5. However, I wanted to make sure that I did not make the same mistake. I still wanted to have the custom methods, but wanted to make sure I could easily apply updates.

The solution was quite simple, and probably one others are using as well. I am simply created a custom cfc (aptly named, in my case, custom.cfc) that extends blog.cfc. Now I can easily update the ‘core’ code, yet still keep my custom methods. The best part about it, I only had to modify 1 file.

First, create your custom component, and place it in the /org/Camden/blog directory. It doesn’t matter what you name the file, for the sake of this example, assume the file is named custom.cfc.

In /client/application.cfm, around line 35, change

view plain print about
1<cfset application.blog = createObject("component","org.camden.blog.blog").init(blogname)>
To
view plain print about
1<cfset application.blog = createObject("component","org.camden.blog.custom").init(blogname)>

Where ‘custom’ would be the name of your file.

Then, in your new component, you need to make sure you have code that looks like this.

view plain print about
1<cfcomponent &extends"blog">
2 <cffunction name="init" access="public" output="false" returnType="custom">
3 <cfargument name="blogName" type="string" required="true" />
4 <cfset super.init(arguments.blogName) />
5 <!---Other code for init() method to run --->
6 <cfreturn this />
7 </cffunction>
8 <!---Custom methods go here --->
9</cfcomponent>

No any custom methods you create can be called by using

view plain print about
1<cfset newMethod = application.blog.customMethod() />

Lastly, anytime you update BlogCFC, just make sure you check /client/Application.cfm to make sure your change did not get over-written.

Also, another method of doing this would be to modify blog.cfc to extend custom.cfc. Either way, you only need to make and keep track of one change in one file, and your custom methods will still exists after an upgrade/update.