Publishing Custom Pages with Movable Type
MT has had the ability to output any content in a template since version 1.0 in 2001, however it doesn't have the "push button" simplicity of Wordpress' Pages feature. For those of you unfamiliar with Wordpress, its Pages feature allows you to create individual static pages (index pages in MT) with the simplicity of the entry screen, i.e. you don't need to worry about the styling or markup - just type out the content and voila, you're done.
This tutorial describes the process to simplify the process of creating standalone pages so that, in essence, you simply need to type out your content. This is useful for using Movable Type as a powerful general content management system.
There are 3 main steps:
- Separate your page content from the general layout.
- Create separate index templates to store your header and footer
- Create an index template to store your content
The first thing you need to do is separate the page's content from the styling and general markup. Open your Main Index Template and select everything from the top of the template to right before the opening <MTEntries> container tag. Copy the selected code into a new index template, name it "Header", and give it an appropriate output file, e.g. "header.html". Next, go back to the Main Index Template, select everything after the closing </MTEntries> container tag and copy that into a new index template called Footer, again with an appropriate output file e.g. "footer.html."
These two files can now be included everytime you want to create a new page, saving you the time it would take to re-create all the general markup like the DockType, stylesheet etc. When creating a new page, you'll want to first include the header file (either using a PHP/SSI include or using MTInclude), then have your content, and finally include the footer file.
You'll need to change certain elements in the header and footer files if you want these sections displayed differently for different pages. You can refer to this tutorial on how to do that but I will give an example here. One thing that will change from page to page is the Title of the page, hence in the header file, replace the title tag with this
<title><MTBlogName> - <?php echo $title; ?></title>
and on every page, you will now need to set the value of $title to be the title you would like for the page, like so (ensure this is before including the header file)
<?php $title = "About Page"; ?>
As described in this tutorial, you can use the MTSetVar/GetVar tags or PHP Variables for other types of conditional display.
If you would like to further simplify the process of creating pages, you can hack edit_template.tmpl so that the header and footer files are automatically included as is the $title variable. Open edit_template.tmpl and between the <textarea> tags, add something like the following (I've used PHP includes, you can replace them with includes of your choice).
<TMPL_IF NAME=NEW_OBJECT> <?php $title = "Page Title"; include('<MTBlogURL>header.html'); ?> <?php include('<MTBlogURL>footer.html'); ?> </TMPL_IF>
What this does is automatically include the header and footer files when you create a new index template.
Movable Type's powerful templating system allows you to create any number of custom index templates. Focusing this power on specific standalone pages is easiest if you make smart use of reusing page elements either through the of external includes or the platform's built-in ability to easily reuse page elements.