Tuesday, April 27, 2010

Using Magnolia's inplace-templating for hot-fixes

I just realized that we forgot to provide a mechanism for the Google-Site-verification meta-tag when we migrated our corporate homepage to Magnolia 4.2 two months ago. For those not acquainted with the subject-matter: this is a way to prove to some third-party service you actually own the site (as in "have the right to modify content"). There are various ways to do so, but the fastest and least intrusive is to add a meta-tag to your html-head section like so:

<meta name="google-site-verification"
content="eGPInzT6lx6Kff8Hb2T3SCvUmnjVWeBg76G_y7PXxBk">
Now, in previous versions of Magnolia that would mean I have to grab a developer, explain what I need and hope she finds time for my request within her tight schedule. Even if she wouldn't be overly busy, starting up a development environment (IDE), checking out the project sources, adding the needed functionality, testing, and then deploying to a live instance (which more likely than not involves someone from operations, too) would be a matter of least an hour, but more likely a week would go by before you see the change in production – plus it is definitely not worth the effort for such a small and single change.

So, after this somewhat long introduction to the issue at hand, Magnolia has a solution that is simple enough for me to use. It is the "inplace-templating" module, which we install by default with Magnolia STK (but STK is independent). It simply allows to edit Freemarker templates directly in the browser, and then enable and activate them.

Here are the simple steps:

1. find the main template in the Templating Kit menu:



2. Open the editor and add the missing meta-data field


3. Check enable template (see above screenshot)
4. Activate the template
Done.

You can check the site's html source to see the change:
So not only is it really trivial to adapt your templates on the fly (BTW, you can also map the templates repository to your filesystem via WebDAV and use your favorite text-editor to change the templates); the real benefit is that you can use this mechanism to do urgent hot-fixes without involvement of anybody else.

Once things work as expected, simply notify your developer and she will roll the hot-fix into the next regular release. This way, nothing gets lost, and the whole process is highly efficient.