Movable Type v4.0 (Athena): A Developer's Perspective

athena-dashboard.png

The big news today is Movable Type 4.0 has gone into beta and will be open sourced once released! Rather than talk about the new features, over 50 new features with a completely redesigned and gorgeous new interface, I thought I'd take a moment to talk about what makes my head reel with Movable Type 4.0, it's developer features.

A long time ago, Six Apart posted the Componentization Guide, an overview of one of the biggest changes in Movable Type history that would completely change the way it was offered. Rather than separate products (Movable Type, Movable Type Enterprise), the application was made completely dynamic. So now, we would have one core product and all the features (such as what you would find in the former MTE) would be available through a new series of addons called components which would seamlessly integrate with Movable Type.

In order for components to properly work, Movable Type was rewritten in large portions and introduces several new features.

  • registry.pngThe new registry - If you're like me, the word registry conjures up horrible images of Windows' mess but Movable Type's registry is a thing of beauty. Whereas previously definitions (like permissions, version numbers and settings) were scattered across several files, with the new registry, these are all pulled together in one location. What makes this so killer? The fact that any plugin (or component) can extend the registry and hence easily define their own permissions, object types and configuration directives (to be used in mt-config.cgi). In fact, one of the things that I feel will completely change the ball game is the fact that you can even extend built in objects. For example, supposing I needed to store a particular bit of data (lets call that foobar for now) on entries for my plugin, with the new registry, I could quite simply do:

    $plugin->registry({
        object_types => {
            'entry' => {
                'foobar' => 'string(255)'
            }
        }
    });
    

    Which would add a new string column to mt_entry and could then be used by my plugin like so:

    $entry->foobar('hello');
    

    And would give me all the associated benefits such as being able to sort by that field (both within my plugin and in the MTEntries template tag)

  • General routines - a pretty vague sounding point, right? But thanks to the Componentization of Movable Type (where things such as Movable Type Enterprise were moved into components), we're now able to re-use a lot of code, procedures and routines within Movable Type. For example, object listings would also be an incredible pain for me to create - there are so many moving parts, the listing, filtering, pagination, display options. I would have to copy a lot of code from CMS.pm to replicate the behaviour. Just an example of some of the fantastic new developer features in MT 4.0, here's the Perl code to creating an object listing now:

    listing-perl.png

    That will populate the loop needed to create your listing, will take care of filters, pagination and display options too. Isn't that just wonderful?

    In the previous point, I highlighted how we could extend MT::Entry with a new column. But what if our plugin wanted to store something that was pretty much an entry but stored slightly different things - a great example of which is MT Blogroll which stored almost identical things to an entry, a title, a description, a status etc. Previously, we would need to go about creating out own tables within the database, copy across hundreds upon thousands of lines of code as we tried to replicate the same functionality. Well no more! Do the new pages look/feel awfully similar to entries? That's because they are! With v4.0, plugins can now ridiculously easily subclass MT::Entry (and MT::Category) for their own purposes without causing any conflicts within the system. Pages are but a special type of entry and soon MT Blogroll's links will, too, be a special type of entry.  Take a look at some of the files in the next version of MT Blogroll to see how this has eased (and quickened) plugin development. With those three files, I've already allowed for new links to be created, edited and listed with the application (something that takes up roughly 400 lines of code in MT Blogroll v2.5!)

  • The new interface - most of the blog posts announcing MT 4 have commented on it's radically redesigned interface (which might I add, is satisfyingly good to use - something I've only ever really felt with Vox). The even bigger news for me is that the new interface is built using Movable Type's built in template tag system (rather than the old and tired HTML::Template). It also introduces several new app template tags. These new template tags can be used within the application and are delicious shortcuts that will truly cut down the grief I face when building my plugins. For example, whereas previously, I would need to copy pages of code to produce a standard object listing screen, I can now simply add the app:listing tag to my .tmpl file and it will do the rest! Similarly, we have the app:setting tag which will produces the standard markup for a field and its setting!

    dom-code.pngBut wait! There's more! As a plugin developer, there's nothing I hate more than Transformer Plugins. Don't get me wrong, the concept of a plugin being able to change the interface is fantastic but the execution left much to be desired. We had to resort to crude search and replace techniques that would search for a line of code and replace it with what we wanted.dom-includes.png This had the lovely effect of breaking plugins at even the most minor of changes. With v4.0, a series of DOM-like methods have been introduced (including getElementById, getElementsByTagName so on and so forth). These methods allow us to easily find fields and markup within app templates and should, hopefully, mean that Transformer plugins are less prone to break. A great example of how these methods work is on the edit template page. New with 4.0, when a template contains an MTInclude tag, a link to the template is automatically shown in the sidebar.

  • Extensible Everything - One of the things I loved about MT 3.3 is that the tagging system was made so open and extensible. Although there were quite large gaps in it, the tagging system essentially allowed anything to be tagged (I meant to write another part to the walkthrough on this subject but never found the time unfortunately!). This saw fruit in plugins like MT Blogroll and Media Manager which allowed you to tag links and media respectively! With v4.0, this extensible concept has been taken ever further with two new frameworks. The first is a rating framework. The rating framework, like it's tagging counterpart, also allows you to rate anything stored within the Movable Type database - I expect links in MT Blogroll will soon be rateable! By default, entries are rateable with a 5-star rating but if that's not your thing, you could quite easily throw together a plugin that would implement a digg-like Up/Down rater. The possibilities are endless

    archive-mapping.pngThe second is an archiving framework and it's a thing of wonder. One of my plugins - CustomFields - allowed author archiving and in it's recent v2.0 overhaul, I looked to rewrite that part of the plugin... and it was hell. I'm happy to say that author archives (along with date-based category and date-based author archives) have been built into v4.0. In addition to that, it is shockingly easy for plugins to add their own archive types. Want yearly archives? Or perhaps author-category archives? Nothing simplier! In fact, an interesting plugin idea would be to allow users to mash their own archiving type together!

mt4-bug-mt-white.pngAnd this entry is just touches the tip of the iceberg. Movable Type 4.0, codenamed Athena, is definitely one of the biggest releases in Movable Type history. Not only does it have truly killer user features (this entire post was typed in Athena's Rich Text editor which not only periodically auto-saved my entry but blows away all competition - including my attempt!) but it is going to usher in a new era of plugin development.

Give Athena a whirl (I'd recommend starting it on a fresh database, not just because it's a beta but because the whole installation experience is new, fresh and down-right rocks!)

10 Comments

Mark Carey said:
on Jun 5, 2007 5:58 PM | Reply

Thanks a bunch for this, Arvind. A very useful intro to developer and customization features in MT 4.0. Now to find the the time to play with it... ;)

umeditor said:
on Jun 5, 2007 7:25 PM | Reply

My head is spinning with possibilities. I was just getting ready to start on a major MT upgrade, but it looks like I might be spending that time on 4.0 testing.

Byrne Reese said:
on Jun 5, 2007 8:17 PM | Reply

Awesome write up Arvind. Thank you so much. More details and documentation will soon be published to movabletype.org to help developers get started in taking advantage of this amazing framework.

Lola LB said:
on Jun 5, 2007 8:19 PM | Reply

I've got this loaded on my laptop now - giving it a twirl. I'm really impressed with the new GUI. A few details do take some getting used to, but overall, so far, so good. looking forward to the next version of MT Blogroll . . .

Arvind Satyanarayan said:
on Jun 5, 2007 8:48 PM | Reply

Oh you'll love the new version of MT Blogroll. Thanks to many of these new features, MT Blogroll is going to be integrated directly into MT rather than feeling like a separate app. It's going to be hawesome!

Tami said:
on Jun 5, 2007 11:46 PM | Reply

Oh, I can't wait for version 4 to come out! It sounds just wonderful. Unfortunately, I can't really rationalize taking the time to beta test right now, because, well, you know I just had a baby a little over a week ago. Yeah, I know, always some lame excuse for for not beta testing. ;)

I'll certainly try to keep up with reading how beta testing is going for the rest of you. Best wishes and happy beta testing!

Jesse Gardner said:
on Jun 6, 2007 8:37 AM | Reply

Dang, Arvind. You nearly got me wanting to write a plugin!

metisdev said:
on Jun 7, 2007 9:40 AM | Reply

Thanks Arvind. I have been waiting for the integration of the rating framework for two years.

demonsurfer said:
on Jun 7, 2007 3:35 PM | Reply

Nice writeup Arvind, looking forward to checking it out. Hope you're well. Cheers.

Rolograaf said:
on Mar 30, 2008 4:47 PM | Reply

This article is old, maybe obsolete, but I am still missing the pictures! (or is a connection problem on my side?)