Tag Archives: Concrete5 Blocks

Bullet proof JavaScript for CMS

A web content management system (CMS) allows editing, styling and publishing of content for a website from a single piece of software. Some common CMS choices include:
  • WordPress
  • Concrete5
  • Joomla
  • Drupal
The main two ways of editing the content in a web based CMS; In page, and off page.

In page, or in-line editing, allows a user to view their changes as they happen in the context of the web site design. Off page editing has a separate section for editing the content so viewing it on page requires the changes to be either previewed, or even saved first.

Each system has its advantages, but where some in page systems really fall down is with regards to JavaScript. JavaScript code executes directly in the web browser to add powerful functionality to a website. The major downside to JavaScript is that it can easily be broken by inexperienced developers and once a single error occurs, the remaining JavaScript fails to execute. 

An example of this happened to us recently when we were adding a third party block to a client’s Concrete5 website. The developer of the block had an intermittent error in their JavaScript code. Once we added the block to a page, we could no longer edit the page to remove the block! The Concrete5 user interface is reliant on JavaScript code, and the error in the third party block was causing the Concrete5 code not to run. Fortunately, we had the know-how to remove the bad block: For those that are stuck on this, you can often revert your pages to an earlier version (that is, a version that doesn’t contain your troublesome block) by accessing the Dashboard > Full Sitemap, clicking on the page in trouble, and selecting Versions.

The really annoying thing, is that this type of problem is incredibly easy to avoid by writing better JavaScript in the first place. Simply detect errors in each code block and deal with them accordingly. This is what we ended up doing with the third party block in this case. 

I want to implore anyone who works with a CMS that allows In Page editing to be more diligent with their JavaScript code and catch and handle exceptions at all times. Just like we do.