Model-Glue tip - Watch out for renamed events

So I think everyone knows that if you redesign a web site, you can potentially end up with renamed files and the like which means old URLs will no longer work. There are multiple ways you can handle this. You can use a URL Rewriter. A 404 handler. Etc.

Well what happens when you update a Model-Glue (or Fusebox, etc) site? If you are like me, you probably have a total and complete brain fart and completely forget. Personally I brain Model-Glue and it’s usage of one main index.cfm.

This past Sunday I helped launch the second version of University Notes. This is a site I built with some friends of mine in college. It has been pretty successful and version 2 was a major update. In that update I changed almost each and every single event name, typically from XXX to page.XXX.

So what happened the day after we launched? I got a whole heck of a lot of error messages about missing events. I covered how to handle these events in the past. (See this blog entry.)

I bring it up since I thought I’d show how I fixed it. Instead of catching the unknown event error, I created a mapping in my Application.cfm file. Here is a snippet:

<cfif structKeyExists(url,"event")> <cfif url.event is "dologinregister"> <cfset url.event = "page.logon"> <cfelseif url.event is "home"> <cfset url.event = "page.index"> <cfelseif url.event is "viewprofile"> <cfset url.event = "page.profile"> <cfelseif url.event is "registerform"> <cfset url.event = "page.register"> ...

I’m sure I’m not the only person to make such a mistake, so keep it in mind if you work to update a large frameworks based site.

p.s. Not that it’s related, but the site also makes heavy use of Spry. Check out the Courses/Ratings/Content tags.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments