ColdBox and ColdCourse Gotchas

While working on my latest ColdBox application, I had a need to implement friendly URL support for the public facing front-end. This is pretty much a requirement for all of our client sites so it was important to use something that worked really well without coming up with some hacky method.

I turned to ColdCourse after reading several posts about how easy it was to setup and use. I quickly found out its not a plug and play solution, it took some work to get it going properly in my application, although nothing difficult, it was just a little more than I expected after reading the docs. During the setup there were a few things that I ran into that I thought you guys might benefit from reading about. But before I get into that, remember, this is ColdBox specific. I have no experience with using ColdCourse with any other frameworks.The first thing I noticed right off was that there was no way to exclude my admin system from using friendly URLs. Some type of an exclusion system would be a very nice addition to ColdCourse. Normally this wouldnt be a big deal, I just didnt want to deal with re-writing all of my URL’s in the admin to use the proper format.

So to prevent my admin system from using ColdCourse, I simply put a conditional in my index.cfm that checks to see if the URL is for the front-end or the admin. This was pretty simple for me since I have only one Event Handler for my entire front-end, its called Display.cfc. So I simply wrapped my call to ColdCourse with the conditional like this:

Since my Event Handler is named display, all of my friendly URLs are in the format:

So we are simply checking for the existence of “display” in the URL. This way, anytime a user is making a call to the public facing part of the website, ColdCourse will be called upon to handle the friendly URL. If the call is to the admin system, ColdCourse is left out of the equation.

The next and only other real issue was a compatibility issue between one of ColdBox’s built-in functions and ColdCourse. Basically, anytime you use the method setNextEvent() in one of your Event Handlers for redirection, it would append the ColdBox URL onto the end of the friendly URL like this:

Since I use setNextEvent() quite often, especially after saving a form, I had to come up with a fix for this. So I created a new method in ColdBox to work specifically with ColdCourse. Im not displaying the code here yet since its not part of the ColdBox release. I have talked to the ColdBox dev team about it a little and I have bit more clean up to do to make sure that it works for all applications. I mainly wanted you guys to be aware of this issue so it may save you a bit of time trying to diagnose the issue if you run into it.

Its been working great for me so far. I havent had one error yet. If your using ColdBox and ColdCourse together and would like the code that I used to implement this, let me know and I will email it to you.

2 thoughts on “ColdBox and ColdCourse Gotchas”

  1. Glad to see it’s working so far! I hadn’t thought about exclusions though, have to think about that one. For converting a site completely to it I suppose it would be nice to be able to do it bit by bit.

  2. Yes its definitely working! Really great solution for friendly urls. Much better than just writing regular expression matches for everything in your rewriter’s ini file like I used to do!

    Thanks for the tool!

Leave a Reply

Your email address will not be published. Required fields are marked *