Movable Type User Manual: TEMPLATES

« Table of Contents


TEMPLATES

Templates in the Movable Type system are your method of defining the design and layout of your site. Templates describe where you want your content (that is, your entries and archives), what that content should look like, and so on. Generally your templates will be made up of HTML, interspersed with Movable Type template tags and variables (see TEMPLATE TAGS), but this is not a technical limitation; you can use Movable Type to generate plain text, HTML with server-side includes, PHP, and any other text-based language.

You can edit your weblog's templates, and define new templates, by logging in to Movable Type, selecting a weblog, then clicking List & Edit Templates.

There are several different types of templates in Movable Type.

Index Templates

Index templates are your main entry listings. Unlike many other weblog management systems, Movable Type supports multiple index templates; this means that you can publish your main entry listings in several formats, for example, like one listing in HTML, and one in XML. By default, an index template displays the last N days worth of entries, where N is defined in your weblog configuration. For example, if you set the number of days displayed on the index to 7, Movable Type will, by default, display all entries from the last 7 days on all of your index templates. Note that 7 days means the last 7 consecutive days, not necessarily the last 7 days on which you posted an entry. So if you have posted on just 3 of the last 7 days, only the posts from those 3 days will be listed on your main indexes.

As mentioned above, displaying the last N days of entries is the default behavior for index templates; this behavior is customizable, however, through the MTEntries tag (see below); for example, you might set your RSS index (for RSS syndication) to display your last 15 entries, no matter the date.

Archive Templates

Archive templates define the look and feel or your weblog archives. For each archive type that you choose (see ARCHIVING), you can associate multiple archive templates with that archive type; this allows for different ``views'' of the same set of archived entries. For example, you might wish to create two different views of your monthly archives: a page containing each of the entries for a particular month, and a calendar view of that month. Or, you could use different templates to create hi-fi and lo-fi versions of your archives.

When an archive type is rebuilt, all of the archive templates associated with the archive type are rebuilt--this allows you to automatically maintain several views of the same archived entries.

Movable Type ships with three archive templates: one for the date-based archives (Monthly, Weekly, and Daily), one for your Category archives, and one for your Individual entry archives.

To define a new Archive Template, go to List & Edit Templates, and click Create new archive template. Name the template, then define the layout for the archive page using Movable Type template tags. After you have saved the new archive template, go to the Archiving section of your Weblog Configuration, and click the ADD NEW... button; in the popup window, select the template you just created from the Template: pulldown menu, and select the archive type with which you'd like to associate that template from the Archive Type: menu. Then click ADD.

Template Modules

Movable Type allows you to extract common chunks of HTML code into templates that you can then include in your other templates; in Movable Type, these common templates are called Template Modules. An example of the use for such a template might be a header that you use throughout your site. You can create a new template module called Header, paste in the common header code, then save the new template. You can then include this code in all of your other templates using the MTInclude tag:

<$MTInclude module="Header"$>

This tag will be replaced by the contents of the Header custom template.

This allows you to keep all common code in one place, so that if you need to modify it, you only need to modify it in one place.

Miscellaneous Templates

These are the templates that don't fit as Index Templates, Archive Templates, or Custom Templates. Currently, the templates in this category are:

Editing a Template

After selecting a template to edit in the List & Edit Templates screen--either by clicking on the name of an index template or a template module, or by clicking the EDIT button for the archive or miscellaneous templates--you will be presented with the Edit Template screen. Depending on the type of template you are editing, or whether you are editing a template module, the template-editing screen will differ slightly in appearance. For example, only on an Index Template will you be able to assign an Output file.

Here are the fields you may be presented with on the Edit Template screen:

Default Templates

Movable Type ships with a set of default templates that are customizable through stylesheets; the same template markup can be made to look completely different by inserting a new stylesheet. You can view the default templates themselves at http://www.movabletype.org/default_templates.shtml .

To select a new style for your weblog, follow these instructions:

  1. Log in to Movable Type, select the weblog you wish to edit, then click List & Edit Templates.

  2. In the list of Index Templates, you will see a template called Stylesheet; open this template for editing.

  3. The prebuilt stylesheets used to customize your pages are located at http://www.movabletype.org/default_styles.shtml . On this page, you can view screenshots of each style; once you have selected the style you wish to use, copy the contents of the text box, and paste those contents into the Template body box of the template you opened for editing in Step 2.

  4. Press the SAVE button to save the new stylesheet.

  5. You will be prompted to rebuild your site; click the REBUILD link, select Rebuild Indexes Only from the pulldown menu, and click the REBUILD button.

  6. When the rebuild has completed, your site will now be using the new stylesheet.

    NOTE: some browsers (Internet Explorer for Windows, for one) refuse to reload a stylesheet from the webserver once they have fetched it once; if, when you view your site, nothing has changed, you should empty your browser cache and try again.


Copyright © 2001-2003 Six Apart. All Rights Reserved.