Customizing Movable Type's Interface with Application Templates
Introduction
This article explains how you can customize the user interface of the Movable Type application. This is a powerful area of functionality that's easy to get started with and almost unlimited in its potential. Some key points we'll cover: * How to create custom application templates for Movable Type's interface * The benefits of using application templates * Ideas for how to use application templates with your plugins or workflow * Links to some example application templates, to see what's possible and to inspire your ownCustomizing the Movable Type user interface
To understand the potential of customizing your Movable Type interface, you'll need a little bit of background. Most Movable Type users are familiar with the templates that are used to generate HTML or XML files for output. But Movable Type also uses another template system, called HTML::Template, to produce the HTML files that define the application's user interface. This system allows for flexibility such as limiting the display of certain features to only users who have permission to access them. Fortunately, despite their power, the templates that make up the Movable Type interface basically look like standard HTML, with some little bits of logic added.styles.css file in the root of your Movable Type installation and tweak to your heart's content. You can see the results of a number of these types of customizations under the tag "Pimp My CMS".
If you want to follow along in your own Movable Type installation, you should check out the /tmpl directory underneath the directory where you have Movable Type installed. You'll find a subdirectory called cms that contains most of the templates that make up the screens you're familiar with when you log into the system.
What's an AltTemplatePath?
Once you've found thetmpl directory, it's pretty easy to understand the next few steps. Movable Type allows you to simply override the default application templates in this directory with ones of your own creation by making templates with the same name, putting them in a folder that the application can access, and then telling the system where to find them. For our examples, we'll assume that your custom application templates will live in a folder called /exttmpl underneath your Movable Type install. (That puts the exttmpl folder right next to the tmpl folder for easy access, and the "ext" part of "exttmpl" stands for "external" templates.)
The configuration setting for the path to custom (or "alternate") templates is AltTemplatePath. To tell Movable Type where to find your application templates, you need to edit the mt.cfg file, which contains the system configuration for Movable Type. Just edit the file and add a line that says:
AltTemplatePath ./exttmpl
Once you've saved the mt.cfg file, you're all set: Movable Type will always look in the /exttmpl directory first to see if there's an application template available, and if it finds one, it will use your custom template in place of the ones built into the system.
A Simple Example
If you're just getting your feet wet with modifying the Movable Type user interface, the best place to start is by customizing the templates that come with the application. We'll copy one of the existing templates from the/tmpl/cms directory to /exttmpl/cms. For this example, header.tmpl, which generates the top of the page and the left toolbar for the Movable Type application, will serve our purposes. After you've copied header.tmpl to its new location, open it up in a standard text editor.
The line we'll want to edit for our example is line 28 ofSide Note: In Movable Type's user interface templates, you'll see some standard HTML laying out the structure of the page, as well as some new tags that you may not be familiar with. The items that start with
TMPL_VARare template variables, which Movable Type generates depending on your system configuration. The ones starting withMT_TRANSare bits of text that are translated into the language selected by the user. (Movable Type has been professionally translated into half a dozen languages, and it's also possbile to create your own translations.) A full explanation of this template language is outside the scope of this article, but if you want to learn more the language used here, you can start with HTML::Template Explained. Full resources, including a mailing list, are available at the SourceForge site for the project.
header.tmpl in version 3.16 of Movable Type. Before any changes, it looks like this:
<TMPL_IF NAME=BLOG_NAME>| <a target="_blank" href="<TMPL_VAR NAME=BLOG_URL>"><MT_TRANS phrase="View Site"></a></TMPL_IF>
If you've worked within Movable Type a lot and use a tabbed browser or are just meticulous about managing your browser windows, you probably already know what this (potentially annoying) bit of markup does: It's the "View Site" link on the top navigation in Movable Type. By default, it opens a new window to display your blog when you click on it. If you're administrating a blog for a workgroup in a company, opening in a new window might be a handy convenience for many of the authors who contribute to the weblog. But we're power users! We're in here mucking around with our application's templates! So we can't have Movable Type be coddling us by opening up new windows on its own.
How do we fix this annoying habit? We just take out the markup that's instructing the browser to open up the new window: The target="_blank" attribute. So let's replace line 28 of header.tmpl with this new version:
<TMPL_IF NAME=BLOG_NAME>| <a href="<TMPL_VAR NAME=BLOG_URL>"><MT_TRANS phrase="View Site"></a></TMPL_IF>
Then, just save the modified file, make sure it's located in /exttmpl/cms, and log in to your Movable Type installation. You should be able to click on "View Site" from the top navigation of any of your weblogs to verify that the changes worked.
Your Changes Are Safe
One of the most satisfying parts of working with application templates for Movable Type's interface is that your changes, improvements, or customizations to the Movable Type user interface are safe. If you upgrade Movable Type, the/exttmpl folder isn't overwritten, so your templates will continue to work. (Though, if the user interface for Movable Type is revised, you won't get any new functionality that's made available in the new version's templates.)
In addition, your application templates can make use of the hundreds of strings that are localized for each of the international versions of Movable Type. If you make smart use of translated variables (refer to the HTML::Template links, above), your customizations will work for Movable Type users around the world, taking advantage of the translation work that's already been done.
And the application templates that make up the Movable Type interface are being made available under the Artistic License, allowing you to customize the templates and redistribute them as needed, either for your own use, for your customers, or to share with the entire Movable Type community.
Best of all, we'll be expanding support for application templates in future releases, to include items such as the email templates used for notifications from the Movable Type application. Once you've created a library of customizations encompassing all of your preferences and personalization, you'll be able to deploy it on any of the platforms where Movable Type runs.



3 Comments
Great info, Anil! In the antipenultimate paragraph here, you mention "If you prefer Flash for certain types of interaction, an application template can let you embed Flash within the application."
As graphics editor for a news blog using MT, I have been searching hi and lo for tips/info on just how to do this. In my case, this would simply be Flash animated graphics, insertable like any image (but that doesn't work, I've found, so guess I need to set up a template...). I've been using .swf files exported as animated .gifs in the meantime, but the Flash versions are so much better (cleaner, smoother, scalable), I sure would like to be able figure that one out. Any suggestions?
The URL above is an example.
Oops, left out the URL (example):
http://www.siliconvalleywatcher.com/mt/archives/2006/02/the_battle_for.php
Customizing Movable Type's Interface with Application Templates - thanks for great article. Greetings