Introduction of sorts
Previously, I went over the process of converting your WordPress entries, comments and pings over to Movable Type. Now, here comes the real fun part. Rewriting your template! Yeah, you know you want dive right in there and replace all of those PHP function calls with Movable Type template tags. Don't start this unless you are willing to devote up to a few hours of your time testing and tweaking. I highly recommend that you do not import your entries into your database until you have completed this phase.Alright. Movable Type and WordPress have pretty similar template paradigms. Archives are both based on a looping mechanism that iterates over the appropriate number of entries for a given archive. In WordPress, "The Loop" is what gets this fun started, and in Movable Type, <MTEntries> is its approximate match. What's important is that the magic which causes your archives to be generated happens inside of these loops. From that point on, the important tags/function calls act from that perspective.
Generally speaking, the safest way to get things started is to open up a WordPress template file such as index.php and save it as a new file such as index.template. This will make preserving the layout a lot easier than doing a cut-and-paste job. Go through and start systematically taking out all of the PHP code blocks, replacing them with the appropriate Movable Type template tags.
We're going to do this visually where possible, so here are three illustrated screenshots to get us started with the main template/index template:
Now, if you compare the first two entries with the third, you will notice that they are very, very similar. Movable Type eschews the usage of PHP, Perl and other languages in favor of special markup tags that execute commands on the server side.
The PHP foreach loop becomes a <MTEntries< block, which is the Movable Type equivalent. The WordPress function calls such as the_content(); are also almost 1:1 mappable to equivalent Movable Type variables or markup commands. The only big difference, if any is that the Movable Type version contains some conditional tags which cause it to do slightly different things if certain information, such as the author, is not availible.
In general, the other archive templates in Movable Type function similarly to the index template so it is not particularly difficult to translate these concepts from the main index template which was converted here, to the date-based, category-based and individual archives. The main difference is that with the individual archive template you will need to drop the <MTEntries> tags so that only one post is retrieved per individual archive.
How to get your categories and archives listed in the sidebar
The WordPress PHP call for this is actually pretty simple, it's just wp_list_cats('sort_column=name&optioncount=1');. However, the MovableType version is a lot more flexible, and as a result, complicated. The example that I provide is one that is taken from the default main archive template used in Movable Type 3.2. It recursively lists your categories in a hierarchical display via a series of unordered lists.
<MTIfArchiveTypeEnabled archive_type="Category"> <div class="module-categories module"> <MTTopLevelCategories> <MTSubCatIsFirst> <ul class="module-list"> </MTSubCatIsFirst> <MTIfNonZero tag="MTCategoryCount"> <li><a href="<$MTCategoryArchiveLink$>" title="<$MTCategoryDescription$>" ><MTCategoryLabel></a> <MTElse> <li><MTCategoryLabel> </MTElse> </MTIfNonZero> <MTSubCatsRecurse> </li> <MTSubCatIsLast> </ul> </MTSubCatIsLast> </MTTopLevelCategories> </div> </MTIfArchiveTypeEnabled>
The first step is that it checks to see if you have enabled the category archive type. Movable Type allows you to define which types of archives that you want to have generated, and if category archives are one of those, then you will be able to display a list of categories. If they aren't enabled, Movable Type will not generate the index files for the categories, resulting in there being no valid links to point to.
In this example, Movable Type checks to see for categories and then moves forward from there. The top level is treated the same as a deeper level by this markup. As it goes over each level, it checks to see if there are entries associated with a category, and if so, it points a link to the index for that category. Otherwise, it puts a placeholder there. If there is a child category associated with a top level category, once this code reaches the top level category with the child, it will execute itself again inside the top level category, resulting in a new list being appended at that node.
Take a look, to see what I mean, if you are kinda hazy on recursion:
A similar trick will work for generating monthly archives. You will not need to do recurisve listing for these entries. Something that looks like the following will work:
<MTArchiveList archive_type="Monthly"> <MTArchiveListHeader> <ul> </MTArchiveListHeader> <li><a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a></li> <MTArchiveListFooter> <ul> </MTArchiveListFooter> </MTArchiveList>
Creating a blogroll
There are two easy ways to create blogrolls. You can download the MT Blogroll Plugin which is a pretty cool plugin, or you can create template modules. The advantage of the former is that it allows you to control your blogroll from a centralized administration console, but it doesn't seem to be so good with multiple blogrolls right now as of version 2.12. The advantage of the second approach is that all you need to do in order to include them is use an <MTInclude> tag.
Jumping back and forth between archived posts
There are two tags that allow you to access the previous and next post. They are the container tags <MTArchivePrevious> and <MTArchiveNext>. Archive links created within these tags will point to the next or previous archive type. All archive variables called within these container tags will be set according to the next or previous archive.
Miscellaneous
There is no silver bullet for converting WordPress templates to Movable Type, but this overview should get you started very quickly on making the transition. A few remaining recommendations for the complete beginner:
- Organize your new Movable Type template similarly to how the WordPress template was created. For example, replace the get_header(); PHP function with an <MTInclude> that references a template module named "Header."
- Borrow where appropriate for Movable Type-specific things such as the comment entry form from the default templates if you need to.
- Take advantage of the ability to store your template data in the database.
Akismet is availible for Movable Type! So make sure that one of the first things that you do is download Akismet and install it. It configures as easily with Movable Type as it does with WordPress.
Additional references:
Related Entries:
- Coming soon to a Movable Type blog near you
- My recent work on Movable Type
- Comments?
- Late night geek thoughts
- What do you think?
- A cool template trick for Movable Type users
- Updates
- Dynamism is the solution to all of life's problems
- Random thoughts
- WordPress users need to stop using this tired excuse


I'm curious why you're switching from WordPress to MT. Doesn't it seem like the development momentum is on the WP side of things these days?
(Found you via your self-link @ Slashdot; liked the article; looked around-veni, vidi, ...vidi some more.)
It started over the finger pointing between Dr. Dave of SpamKarma fame and some of the developers over a security hole then went on from there. I actually liked Movable Type better in a number of ways, it's just that WordPress had better spam protection at the time.
One of the things that I do really like about Movable Type is the static page support. I had a few incidents where my host's database went down and my blog was entirely down for a while and it drove home the value of having static pages for my blog.
I have nothing against WordPress, it's just that I prefer Movable Type. I think that WordPress is a good system, but Movable Type appeals to me more personally.