TEMPLATE TAGS

### Movable Type User Manual: TEMPLATE TAGS

« Table of Contents

- TEMPLATE TAGS

- Weblog Data
- Entry Listings/Archive Pages
- Comments
- Comment Previewing
- Archive Templates and Master Archive Index
- Category-Related Tags
- Calendar Display Tags
- TrackBack Tags
- Search Results Tags
- Miscellaneous Tags
- Global Tag Attributes
- Date Tag Formats

# TEMPLATE TAGS

Movable Type templates are composed of special tags embedded within standard chunks of plain text (or HTML, as the case may be). Certain tags are ``container'' tags: they contain what might be called a subtemplate, a chunk of text and MT tags between two other MT tags. Typically a container tag represents either a loop or a conditional.

Non-container tags are simple variable tags: they are placeholders for dynamic pieces of information.

All Movable Type tags are enclosed within less-than greater-than signs, just like HTML tags. You can optionally insert a `$` inside these signs, like this:

    <$MTEntryBody$>

This can be useful to quickly determine whether a particular tag is an HTML tag or a Movable Type tag.

Movable Type tags take attributes to modify their behavior. Tag attributes work similarly to HTML tag attributes: they are lists of `name="value"` pairs, separated by spaces. For example:

    <MTEntries author="Foo" category="Bar">

(Look at the `MTEntries` documentation to determine what this does.)

Attribute values must be enclosed in quotes; otherwise they will not be parsed correctly. When using attributes in a tag where you are using the `$` character after the start and before the end tags, you should place the attributes before the end `$` character. For example:

    <$MTEntryDate format="%B %e, %Y"$>

Some tag attributes are global; they apply to all Movable Type variable substitution tags. Global attributes are discussed below in Global Tag Attributes. Other attributes are tag-specific; they apply only to certain tags. These attributes are listed along with the tags that they apply to, below.

Some Movable Type tags are context-sensitive. For example, it only makes sense to use an `MTComments` tag in the context of a particular entry: for example, in a `Comments Popup` template, or in an archive template designed for use with `Individual` entry archives.

## Weblog Data

- MTBlogs
  A container tag representing a list of all of the weblogs in the system. This includes weblogs that you (as the person editing the template, or rebuilding the page) have access to, and those that you don't. You can use any of the `<$MTBlog*$>` tags inside of these container tags.

- MTBlogID
  The numeric ID of your weblog.

- MTBlogName
  The name of your weblog, as specified in the Weblog Configuration screen.

- MTBlogDescription
  The description of your weblog, as specified in the Weblog Configuration screen.

- MTBlogURL
  The absolute URL of your weblog, as specified in the Weblog Configuration screen.

- MTBlogArchiveURL
  The `Archive URL` of your weblog, as specified in the Weblog Configuration screen.

- MTBlogRelativeURL
  The relative URL of your weblog, as extracted from the Site URL setting in your Weblog Configuration screen. This can be very useful in setting up staging versions of your site, because you do not have to hard-code any URLs into your templates.

- MTBlogSitePath
  The Local Site Path of your weblog, as specified in the Weblog Configuration screen.

- MTBlogHost
  The hostname piece of the absolute URL of your weblog. For example, if your `Site URL` (in the Weblog Configuration screen) were http://www.your-site.com/blog/, the hostname piece would be `www.your-site.com`.

  By default, if your weblog URL specifies a port number, the port number will be included in the value of this tag. You can remove it by setting the `exclude_port` attribute of this tag to `1`.

- MTBlogTimezone
  The timezone you have selected for your weblog, displayed as an offset from UTC in `+|-hh:mm` format. For example, a timezone that is `4` hours ahead of UTC would be displayed as `+04:00`.

- MTBlogEntryCount
  The number of entries in the weblog.

- MTBlogCommentCount
  The number of comments in the weblog.

- MTBlogCCLicenseURL
  The URL corresponding to information about the Creative Commons license that you have chosen.

- MTCCLicenseRDF
  Outputs the machine-readable RDF corresponding to the Creative Commons license that you have chosen.

  This tag is context-sensitive: if you use it in an entry context, the RDF will contain additional information relevant to the entry in question. Otherwise, it will contain generic weblog information.

- MTBlogIfCCLicense
  A container tag whose contents will be evaluated if you have selected a Creative Commons license in your weblog configuration, and will not be evaluated otherwise.

## Entry Listings/Archive Pages

- MTEntries
  A container tag representing a list of entries/posts from your weblog. The actual list of posts can be configured using the optional attributes to this tag. The default is to display the last `N` days of entries, where `N` is the number of days you have set in your configuration for this particular weblog. To alter this behavior, you can provide one of the following attributes:
  - lastn=``N''
    Display the last `N` posts to this weblog, where `N` is some number greater than 0.

  - offset=``M''
    When used with `lastn` (above), starts `M` entries from the most recent, then displays the `N` most recent posts. For example, if you use the following tag:

        <MTEntries lastn="5" offset="5">
        ...
        </MTEntries>

    this will display entries 6-10 (inclusive).

    NOTE: this only works when used with `lastn`.

  - category=``category name''
    Display all posts from the category `category name`. Note that this can be a long list of entries, and you may want to use `lastn` to only display a certain number of entries.

    If you wish to pull entries from several categories, or to restrict entries to those that are assigned to several categories, `category name` can include boolean `AND` and `OR` logic. Note that it can only include one or the other, however, so you cannot say `Foo AND Bar OR Baz`--that will not work. You can only say `Foo AND Bar AND ...` or `Foo OR Bar OR ...`.

    For example, if you wished to list all entries assigned to both `Foo` and `Bar` you could use:

        <MTEntries category="Foo AND Bar">
        ...
        </MTEntries>

  - author=``author name''
    Display all posts by the author `author name`. Note that this can be a long list of entries, and you may want to use `lastn` to only display a certain number of entries.

  - days=``N''
    Display all posts less than `N` days old.

  - recently_commented_on=``N''
    Display the `N` most recently commented-on entries. Each entry will appear in the list only once, so if, for example, a comment is posted to Entry A, then a comment to Entry B, then another to Entry A, there will be two entries displayed: Entry A, then Entry B.

  - sort_order=``ascend|descend''
    Specifies the sort order for this particular `<MTEntries>` tag; this can be used to override the globally set Sort Order for Entries, set in your weblog configuration. Valid values are `ascend` and `descend`.

    In this context, `ascend` and `descend` do not mean only chronological order; this attribute can be used along with `sort_by` (below) to sort, for example, by entry title, either A to Z (`ascend`), or Z to A (`descend`).

    The default value is `descend`.

  - sort_by=``field name''
    Sort by a field other than the Authored On Date of the entry. Valid values for `field name` are `title`, `status`, `modified_on`, `author_id`, or `excerpt`.

    The most obvious use of this attribute might be to alphabetize your entries, rather than displaying them chronologically. For example, suppose that you are using Movable Type to display a dictionary site. You might wish to group your entries by letter, so you could create 26 categories, A through Z. To build a list of all of the entries in your dictionary, grouped by letter, and sorted alphabetically (assuming that you have entered the word or phrase as the title of each entry), you could do this:

        <MTCategories>
        <$MTCategoryLabel$><br />
        <MTEntries sort_by="title" sort_order="descend">
        <a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
        </MTEntries><br />
        </MTCategories>

  NOTE: you can combine `lastn`, `category`, and `author` to filter the list of entries (`days`, however, should be used by itself; if it is used with any other attribute, the other attribute will override it). For example, you can supply both `lastn` and `category` to `MTEntries`; doing this does just what you would expect: it displays the last N entries in a particular category. If you wished to filter that further, by author name, you could supply all three of `lastn`, `category`, and `author`:

      <MTEntries category="Fun" author="Me" lastn="10">
      ...
      </MTEntries>

  This would display the last 10 entries by author `Me` in the category `Fun`.

- MTEntryTitle
  The title of this entry.

- MTEntryStatus
  The Post Status of this entry (either `draft` or `publish`). This isn't particularly useful in most situations, since on your weblog, only entries with a status of `publish` will be displayed. It is used when exporting your data through the Export Mechanism.

- MTEntryExcerpt
  The excerpt of this entry. If you have not provided an excerpt for this entry, the first 20 words of the entry, followed by an ellipsis (`...`) will be used, instead.

  If you have provided an excerpt for the entry, note that line and paragraph breaks will not be converted unless you use the `convert_breaks` attribute to this tag:

      Excerpt with line breaks converted:
      <$MTEntryExcerpt convert_breaks="1"$>

- MTEntryBody
  The main text of this entry.

  If you have turned on automatic line and paragraph break conversion by checking `Convert line breaks` for this entry, paragraphs--blocks of text separated by two line breaks--will be enclosed within <p> and </p> tags, and for each single line break remaining, a <br /> tag will be inserted.

  Note that you can override the entry-specific `Text Formatting` setting by providing this tag with the `convert_breaks` attribute; if this attribute is present, it always overrides the entry setting. So, for example, if you have the entry setting turned on, but wish to turn it off for a specific instance of this tag, you can do so like this:

      <$MTEntryBody convert_breaks="0"$>

  Note also that if you want to display only the first N words in the entry body, you can use the words attribute. For example, the following will show the first 5 words of the entry body.

      <$MTEntryBody words="5"$>

  To find the first N words, HTML is first removed from the entry body, then the body split on whitespace.

- MTEntryMore
  The extended (``more...'') text of this entry.

  If you have turned on automatic line and paragraph break conversion by checking `Convert line breaks` for this entry, paragraphs--blocks of text separated by two line breaks--will be enclosed within <p> and </p> tags, and for each single line break remaining, a <br /> tag will be inserted.

  Note that you can override the entry-specific `Text Formatting` setting by providing this tag with the `convert_breaks` attribute; if this attribute is present, it always overrides the entry setting. So, for example, if you have the entry setting turned on, but wish to turn it off for a specific instance of this tag, you can do so like this:

      <$MTEntryMore convert_breaks="0"$>

- MTEntryLink
  An absolute URL pointing to the archive page containing this entry. If you have selected multiple archive types, the archive URL depends on the type you have selected as your `Preferred Archive Type`. This is the default behavior; to override it you can provide this tag with the attribute `archive_type`, setting it to the archive type you wish to link to.

  For example, say that you have selected `Individual` archiving as your `Preferred Archive Type`. The following tag:

      <$MTEntryLink$>

  would produce a link to the individual entry archive page for this entry. That file name would be the ID of the entry, zero-padded to 6 digits, followed by your weblog's `Archive File Extension` (eg. `html`).

  If you had also enabled `By Category` archiving for this weblog, though, you might wish to link instead to the category archive for a particular entry. To do this, you could use this tag:

      <$MTEntryLink archive_type="Category"$>

  This tag would be substituted by a link to the category archive page for this entry.

  If you want true permalinks--that is, links that will always link to a particular entry, even when it is archived on a page with several other entries--you should use the `<$MTEntryPermalink$>` tag.

- MTEntryPermalink
  An absolute URL pointing to the archive page containing this entry, with an anchor (`#`) pointing to the actual entry (by ID). This is the same as `<$MTEntryLink$>`, but smarter, in that it includes the anchor in all cases except individual archives, where the anchor is redundant.

  Like `<$MTEntryLink$>`, this tag takes an optional attribute `archive_type` to specify the archive type to link to.

- MTEntryKeywords
  The value of the Keywords field in the new/edit entry screen.

- MTEntryAuthor
  The name of the author of this entry.

- MTEntryAuthorNickname
  The nickname of the author of this entry.

- MTEntryAuthorEmail
  The email address of the author of this entry.

  If the `spam_protect` attribute is provided, the email address will be modified so as to prevent spambots from harvesting it. The web browser, however, will still display the email address properly. For example, if the email address is `foo@bar.com`, and you use

      <$MTEntryAuthorEmail spam_protect="1"$>

  the email address will be displayed as `foo&#64;bar&#46;com`.

- MTEntryAuthorURL
  The website URL of the author of this entry.

- MTEntryAuthorLink
  A linked version of the author name. The rules for the linking are as follows: if the author has entered a URL, the author name is a link to that URL; if the author has entered an email address, but no URL, the author name is a link to the email address; if neither email address nor URL are entered, display the author name without a link.

  You can override these rules by using the show_email and show_url attributes to the tag. For example, if you use

      <$MTEntryAuthorLink show_email="0"$>

  then the email address of the author will never be displayed. The logic then becomes: if the author has entered a URL, the author name will be a link to that URL; if no URL, display the author name without a link.

  If the `spam_protect` attribute is provided, and the email link is to be displayed, the email address will be modified so as to prevent spambots from harvesting it. The web browser, however, will still display the email address properly. For example, if the email address is `foo@bar.com`, and you use

      <$MTEntryAuthorLink spam_protect="1"$>

  the email address will be displayed as `foo&#64;bar&#46;com`.

- MTEntryDate
  The date of this entry. Like all date tags, this tag takes optional `format` and `language` attributes. See Date Tag Formats for more information.

- MTEntryModifiedDate
  The modification date of this entry. Like all date tags, this tag takes optional `format` and `language` attributes. See Date Tag Formats for more information.

- MTEntryCommentCount
  The number of comments on this entry.

- MTEntryTrackbackCount
  The number of TrackBack pings on this entry.

- MTEntryTrackbackData
  An RDF dump of TrackBack data about this entry, for use by the bookmarklet. This dump will be invisible to a browser.

- MTEntryTrackbackLink
  If Allow Pings is turned on for this entry, the TrackBack ping URL that can be used to ping the entry.

- MTEntryTrackbackID
  The numeric ID of the TrackBack item corresponding to this entry, if Allow Pings is turned on for the entry. This could be used to construct alternate TrackBack ping URLs, if you wanted to.

- MTEntryIfExtended
  A container tag: the contents of this container will be displayed if this entry has extended text associated with it. This can be useful on an index template for displaying a ``More...'' link, where you only wish to display this link if there is ``more'' text. You could use something like this:

      <MTEntryIfExtended>
      <a href="<$MTEntryLink$>#<$MTEntryID$>">More...</a>
      </MTEntryIfExtended>

- MTEntryIfAllowComments
  A container tag: the contents of this container will be displayed if comments are allowed for this entry (that is, if the `Allow comments` setting is set to either `Open` or `Closed` in the `Edit entry` screen for this entry). You can use this to display a link to comments on this entry, but only (of course) if comments are allowed.

  See the Comments section in ENTRIES (above) for examples of using this tag.

- MTEntryIfCommentsOpen
  A container tag: the contents of this container will be displayed if Allow Comments is set to `Open` for this entry. You can use this to conditionally display the ``Post a comment'' form, for example.

- MTEntryIfAllowPings
  A container tag: the contents of this container will be displayed if TrackBack pings are allowed for this entry (that is, if the `Allow Pings` setting is turned on in the `Edit an entry` screen for this entry).

  See the TrackBack documentation for examples of using this tag.

- MTEntryID
  The numeric ID of this entry. This is useful for creating anchors for permalinks, and when linking to permalinks. By default the entry ID is not padded; in other words, for an entry with ID `8`, this tag will produce only the value `8`. Sometimes you would rather have your IDs padded; in that case, you can use the pad attribute to the `MTEntryID` tag:

      <$MTEntryID pad="1"$>

  This will zero-pad the entry ID to six (6) digits, like `000008`.

- MTEntryCategory
  The name of the primary category in which this entry has been placed.

- MTEntryCategories
  A container tag representing a list of all of the categories--including the primary category--to which entry belongs. Inside of this container you can use any of the `<$MTCategory*$>` tags (documentation) to display information about each category.

  You can supply this tag with the glue attribute to separate each of the categories with a string; this is useful when you wish to separate the category names with a comma, for example. Note that your the value of the glue attribute cannot contain either a single or double quote.

  For example:

      This entry was posted in the following categories:
      <MTEntryCategories glue=", ">
      <a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a>
      </MTEntryCategories>

- MTEntryFlag
  The value of one of the boolean flags for this entry. Currently the two available flags are `convert_breaks` and `allow_comments`. If the flag value is true, the value `1` is displayed; otherwise, the value `0` is displayed. The flag name is passed along in the `flag` attribute. For example:

      <$MTEntryFlag flag="allow_comments"$>

  This tag is used for exporting entry data through the Export mechanism; you probably will not need to use it yourself, in your templates.

- MTEntryPrevious
  A container tag that sets up a context in which all tags refer to the entry previous to the current entry. Inside of an `MTEntryPrevious` context, for example, an <$MTEntryTitle$> tag refers to the title of the previous entry. After you end this context (with a </MTEntryPrevious> tag), tags return to referring to the current entry.

  See the documentation for `MTEntryNext` (below) for an example of usage of this tag.

- MTEntryNext
  A container tag that sets up a context in which all tags refer to the next entry after the current entry. Inside of an `MTEntryNext` context, for example, an <$MTEntryTitle$> tag refers to the title of the next entry. After you end this context (with a </MTEntryNext> tag), tags return to referring to the current entry.

  Here is an example of navigation that links to the previous and next entries, along with a link back to the main index for your weblog.

      <MTEntryPrevious>
      <a href="<$MTEntryLink$>">&lt;&lt; <$MTEntryTitle$></a> |
      </MTEntryPrevious>
      <a href="<$MTBlogURL$>">Main</a>
      <MTEntryNext>
      | <a href="<$MTEntryLink$>"><$MTEntryTitle$> &gt;&gt;</a>
      </MTEntryNext>

- MTDateHeader
  A container tag: the contents of this container will be displayed only if this entry marks a new day in the list of entries. As such this is really only useful inside an `MTEntries` container. For example:

      <MTEntries>
        <MTDateHeader>
          <$MTEntryDate format="%B %e, %Y"$>
        </MTDateHeader>
        Title: <$MTEntryTitle$>
      </MTEntries>

- MTDateFooter
  A container tag: the contents of this container will be displayed only if this entry was posted on a different day than the following (next) entry. This can be used in combination with the `MTDateHeader` tag to wrap all of your posts from a particular day in some sort of structure (a `div`, for example). Like `MTDateHeader`, this tag is only useful inside an `MTEntries` container. For example:

      <MTEntries>
        <MTDateHeader>
          <div class="day">
          <$MTEntryDate format="%B %e, %Y"$>
        </MTDateHeader>
        Title: <$MTEntryTitle$>
        <MTDateFooter>
          </div>
        </MTDateFooter>
      </MTEntries>

- MTEntriesHeader
  A container tag: the contents of this container will be displayed only if this entry is the first entry listed in the `<MTEntries>` container.

- MTEntriesFooter
  A container tag: the contents of this container will be displayed only if this entry is the last entry listed in the `<MTEntries>` container. This could be used, for example, to link to the preview entry's archive page from your index page. If you are using Daily archives, for example:

      <MTEntries days="1">
      ...
      <MTEntriesFooter>
      <MTEntryPrevious>
      <a href="<$MTEntryLink archive_type="Daily"$>">Previously: <$MTEntryDate format="%A, %B %d, %Y"$></a>
      </MTEntryPrevious>
      </MTEntriesFooter>
      </MTEntries>

## Comments

- MTComments
  A container tag representing a list of comments, either on a particular entry or in a particular weblog (depending on the presence of the `lastn` attribute, below).

  If you provide this tag with the `lastn="N"` attribute, where `N` is the number of comments you would like displayed, it will list either the `N` most recent comments on the particular entry--if used in entry context--or the `N` most recent comments in your weblog, if used elsewhere.

  If you do not provide this tag with any attributes, `<MTComments>` will list all of the comments on the particular entry in context. This means, of course, that when using this tag without attributes, it must be used in an entry context: within `<MTEntries>`, in an `Individual entry archive template`, in a `Comment Preview template`, in a `Comment Listing template`, or in a `Comment Error template`.

  By default, the comments will be sorted in the order you have specified for the Order of comments displayed in your weblog configuration. You can override this setting by providing this tag with the `sort_order` attribute, the value of which should be either ascend or descend.

  For example, to display the 6 most recent comments made on any of the entries in your weblog, and sort them in reverse chronological order (most recent first), you can put the following into your Main Index Template:

      <MTComments lastn="6" sort_order="descend">
      <p><$MTCommentAuthor$> said:<br />
      <$MTCommentBody$></p>
      </MTComments>

  For each comment in the list of comments, the text and tags inside the container will be displayed. Each of the tags below are used to display a particular variable piece of a comment.

- MTCommentID
  The numeric ID of this comment. This is useful for creating anchors for comment permalinks, and when linking to permalinks. By default the comment ID is not padded; in other words, for a comment with ID `8`, this tag will produce only the value `8`. Sometimes you would rather have your IDs padded; in that case, you can use the pad attribute to the tag:

      <$MTCommentID pad="1"$>

  This will zero-pad the comment ID to six (6) digits, like `000008`.

- MTCommentEntryID
  The numeric ID of the entry on which this comment was made. This is useful when using `<MTComments lastn="N">`, because it allows you to link to the particular entry on which the comment has been made.

  This tag takes an optional `pad` attribute that works just like the `pad` attribute in `<$MTCommentID$>`, above.

- MTCommentIP
  The IP address of the author of this comment.

- MTCommentAuthor
  The name of the author of this comment.

- MTCommentAuthorLink
  A linked version of the author name. The rules for the linking are as follows: if the author has entered a URL, the author name is a link to that URL; if the author has entered an email address, but no URL, the author name is a link to the email address; if neither email address nor URL are entered, display the author name without a link.

  You can override these rules by using the show_email and show_url attributes to the tag. For example, if you use

      <$MTCommentAuthorLink show_email="0"$>

  then the email address of the author will never be displayed. The logic then becomes: if the author has entered a URL, the author name will be a link to that URL; if no URL, display the author name without a link.

  This is useful when you want to force your visitors to leave their email addresses--that is, you have not checked the Allow anonymous comments checkbox in your weblog configuration--but you do not want to display these email addresses on your weblog.

  If the `spam_protect` attribute is provided, and the email link is to be displayed, the email address will be modified so as to prevent spambots from harvesting it. The web browser, however, will still display the email address properly. For example, if the email address is `foo@bar.com`, and you use

      <$MTCommentAuthorLink spam_protect="1"$>

  the email address will be displayed as `foo&#64;bar&#46;com`.

- MTCommentEmail
  The email address of the author of this comment.

  If the `spam_protect` attribute is provided, the email address will be modified so as to prevent spambots from harvesting it. The web browser, however, will still display the email address properly. For example, if the email address is `foo@bar.com`, and you use

      <$MTCommentEmail spam_protect="1"$>

  the email address will be displayed as `foo&#64;bar&#46;com`.

- MTCommentURL
  The URL of the author of this comment.

- MTCommentBody
  The body of this comment. If you have selected `Convert line and paragraph breaks` in your weblog configuration, paragraphs--blocks of text separated by two line breaks--will be enclosed within <p> and </p> tags, and for each single line breaks, a &lt;br /&gt; tag will be inserted.

  Note that you can override the global `Convert line and paragraph breaks` setting by providing this tag with the `convert_breaks` attribute; if this attribute is present, it always overrides the global setting. So, for example, if you have the global setting turned on, but wish to turn it off for a specific instance of this tag, you can do so like this:

      <$MTCommentBody convert_breaks="0"$>

- MTCommentDate
  The date that this comment was entered on your site. Like all date tags, this tag takes optional `format` and `language` attributes. See Date Tag Formats for more information.

- MTCommentOrderNumber
  The numeric order of a particular comment in the list of comments for an entry, starting at `1`. Note that the order is dependent on the sort order (ascending or descending).

- MTCommentEntry
  A container tag representing the entry on which the comment was made. This allows you to use `<$MTEntry*$>` tags to refer to that entry. For example, you could do

      <MTComments lastn="5" sort_order="descend">
      <MTCommentEntry>
      This comment was made on the entry <$MTEntryTitle$>.
      </MTCommentEntry>
      </MTComments>

## Comment Previewing

When creating the `Comment Preview Template` for use in previewing comments before they are posted to your site, you should use the following tags. All of these tags have the same meaning as the similarly-named tags in `Comments`, above; the only different is that these tags are used for the comment that you are previewing, whereas the others are used inside of an `<MTComments>` block.

- MTCommentPreviewAuthor
- MTCommentPreviewIP
- MTCommentPreviewAuthorLink
- MTCommentPreviewEmail
- MTCommentPreviewURL
- MTCommentPreviewBody
- MTCommentPreviewDate
  These tags all have the same meaning as the similarly-named tags in `Comments`, above.

- MTCommentPreviewIsStatic
  A magic hidden tag that you should use in your `Comment Preview` and `Comment Error` templates so that the system will know where to redirect your users after posting a comment. To use this tag, paste this hidden input field into the forms on your `Comment Preview` and `Comment Error` templates:

      <input type="hidden" name="static" value="<$MTCommentPreviewIsStatic$>">

- MTCommentPreviewState
  NOTE: this tag is deprecated as of version 1.4 of Movable Type. The recommended method of creating comment previews is to use an editable form to allow users to edit the comment being previewed; when you do this, you should NOT use the `<$MTCommentPreviewState$>` tag.

  A magic tag that you need to use on a comment preview page (the `Comment Preview Template`). This tag is substituted with all of the necessary comment data in order to post the comment, as well as knowledge of whether the comment is being posted from inline or popup comments.

## Archive Templates and Master Archive Index

The following template tags and variables apply to your archive pages and to your Master Archive Index.

- MTArchiveList
  A container tag representing a list of all of your archive pages. For each archive page, you can use any of the tag variables below; in addition, you can use an `MTEntries` tag to display information about each of the entries on this archive page. For example:

      <MTArchiveList>
        <a href="<$MTArchiveLink$>"><$MTArchiveDate$></a><br>
        <MTEntries>
          [<$MTEntryTitle$>]
        </MTEntries>
        <br><br>
      </MTArchiveList>

  This will display a link to the archive page, followed by a list of titles of each of the entries on that page.

  This tag takes two attribute: `archive_type`, which specifies the type of archives to list; and `lastn`, which limits the number of archives listed.

  The attribute `archive_type` is optional; if omitted, the listing will use your Preferred Archive Type, or your Archive Type. The attribute is useful when you have selected more than one value for the weblog's Archive Type, and you wish to list the archives for an archive type other than your Preferred Archive Type. For example, if you have chosen to keep both `Individual` and `Daily` archives, and your Preferred Archive Type is `Individual`, you can list your `Daily` archives using this tag:

      <MTArchiveList archive_type="Daily">
      ...
      </MTArchiveList>

  `lastn` can be used to limit the number of archives in the list; for example, if you have 10 months worth of archives in your weblog, and you only wish to list the last 5, you can use this:

      <MTArchiveList archive_type="Monthly" lastn="5">
      ...
      </MTArchiveList>

- MTArchiveLink
  An absolute URL link to this archive page.

  By default, the link is to the archive page of the archive type currently being built; for example, when building a list of `Monthly` archives, `<$MTArchiveLink>` will generate a link to a particular `Monthly` archive. To override this behavior, you can specify the attribute `archive_type`, which should be set to one of the following values: `Individual`, `Daily`, `Weekly`, `Monthly`, or `Category`.

- MTArchiveTitle
  The ``title'' of this archive page. The value of this variable depends on the archive type:
  - Category
    The name of the category.

  - Daily
    The date, in `Month Day, YYYY` form.

  - Weekly
    The range of dates in the week, in `Month Day, YYYY - Month Day, YYYY` form.

  - Monthly
    The month, in `Month YYYY` form.

  - Individual
    The entry title.

  Using `MTArchiveTitle` in combination with `MTArchiveLink` is the easiest way to create your master archive index pages, because the `MTArchiveTitle` value will adapt to whatever type of archiving you choose. For example:

      <MTArchiveList>
      <a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a><br>
      </MTArchiveList>

  No matter what archive type you choose, this will always display a useful list of your archive pages.

- MTArchiveCount
  The number of entries in a specific archive grouping; for example, if you are using Monthly archiving, this corresponds to the number of entries in this month. This tag should only be used inside of a `<MTArchiveList>` container, like this:

      <MTArchiveList>
      <a href="<$MTArchiveLink$>"><$MTArchiveTitle$> (<$MTArchiveCount$>)</a><br>
      </MTArchiveList>

- MTArchiveDate
  The starting date of this archive period. This only makes sense if you are listing `Daily`, `Weekly`, or `Monthly` archives. This is a standard date tag; see below in Date Tag Formats for information on formatting the date.

  You can use this tag inside of an `MTArchiveList` container, and you can also use it in an archive template associated with a date-based archive type, outside of the `MTEntries` tag. You can use this to display a header about the dates represented on a particular archive page--the month and year, for example:

      <$MTBlogName$> Archives: <$MTArchiveDate format="%B %Y"$>
      <MTEntries>
      ...
      </MTEntries>

- MTArchiveDateEnd
  The ending date of this archive period. This only makes sense if you are in a `Daily`, `Weekly`, or `Monthly` archive context, and will fail in any other situation. This is a standard date tag; see below in Date Tag Formats for information on formatting the date.

  You can use this tag in the same scenarios as the `<$MTArchiveDate>` tag.

- MTArchiveCategory
  The name of the category of this archive list. This only makes sense if you are listing `Category` archives.

  You can use this tag inside of an `MTArchiveList` container, and you can also use it in an archive template associated with your `Category` archives, outside of the `MTEntries` tag. You can use this to display a header about the category of entries represented on a particular archive page. For example:

      <$MTBlogName$> Archives: <$MTArchiveCategory$>
      <MTEntries>
      ...
      </MTEntries>

- MTArchivePrevious
  A container tag that sets up a context in which all tags refer to the archive previous to the current archive. Inside of an `MTArchivePrevious` context, for example, an <$MTArchiveTitle$> tag refers to the title of the previous archive. After you end this context (with a </MTArchivePrevious> tag), tags return to referring to the current archive.

  This tag should be used in archive templates that you associate with `Daily`, `Weekly`, or `Monthly` archives; if you want a similar behavior in your individual entry archives, take a look at the `<MTEntryPrevious>` tag.

  By default the ``previous'' archive is based on the type of archive on which the tag is found--for example, in a `Daily` archive, the ``previous'' archive is the previous day with an entry. If you would like to override this behavior--for example, if you'd rather link to the previous month's archives--you can use the `archive_type` attribute (see below for an example).

  See the documentation for `<MTArchiveNext>` (below) for an example of usage of this tag.

- MTArchiveNext
  A container tag that sets up a context in which all tags refer to the next archive after the current archive. Inside of an `MTArchiveNext` context, for example, an <$MTArchiveTitle$> tag refers to the title of the next archive. After you end this context (with a </MTArchiveNext> tag), tags return to referring to the current archive.

  This tag should be used in archive templates that you associate with `Daily`, `Weekly`, or `Monthly` archives; if you want a similar behavior in your individual entry archives, take a look at the `<MTEntryNext>` tag.

  By default the ``next'' archive is based on the type of archive on which the tag is found--for example, in a `Daily` archive, the ``next'' archive is the next day with an entry. If you would like to override this behavior--for example, if you'd rather link to the previous month's archives--you can use the `archive_type` attribute.

  Here is an example of navigation that links to the previous and next archives, along with a link back to the main index for your weblog.

      <MTArchivePrevious>
      <a href="<$MTArchiveLink$>">&lt;&lt; <$MTArchiveTitle$></a> |
      </MTArchivePrevious>
      <a href="<$MTBlogURL$>">Main</a>
      <MTArchiveNext>
      | <a href="<$MTArchiveLink$>"><$MTArchiveTitle$> &gt;&gt;</a>
      </MTArchiveNext>

  Here is an example of navigation that could be used on a `Daily` archive to link to the previous and next month's archives. This might be useful if you use a calendar on all of your `Daily` archives, and want to link to the next and previous month's calendar.

      <MTArchivePrevious archive_type="Monthly">
      <a href="<$MTArchiveLink archive_type="Monthly"$>"><$MTArchiveDate format="%b"$></a>
      </MTArchivePrevious>
      <MTArchiveNext archive_type="Monthly">
      <a href="<$MTArchiveLink archive_type="Monthly"$>"><$MTArchiveDate format="%b"$></a>
      </MTArchiveNext>

## Category-Related Tags

The following tags can be used to display a list of the categories in your weblog, and information about each category (ID, label, etc.).

- MTCategories
  A container tag representing a list of the categories in your weblog. For each category, you can use any of the tag variables below; in addition, you can use an `<MTEntries>` tag to display information about each of the entries in this category. For example:

      <MTCategories>
        <a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a><br>
        <MTEntries>
        <$MTEntryTitle$>&nbsp;
        </MTEntries>
        <br /><br />
      </MTCategories>

  This will display a link to each of your categories, each followed by a list of titles of the entries in that category.

  When a category does not contain any entries, by default that category will not be included in the list of categories; this is the default behavior because it mirrors the behavior of `<MTArchiveList>`. Note that this is advised if you are including links to your category archive pages, because archive pages are not generated for empty categories. Thus, the archive link for an empty category will be a broken link.

  If you would like to override this default behavior, you can provide this tag with the `show_empty` attribute. For example, these tags:

      <MTCategories show_empty="1">
      <$MTCategoryLabel$>
      </MTCategories>

  will display a list of all of your categories, even those that are empty.

- MTCategoryID
  The numeric ID of the category.

- MTCategoryLabel
  The category label.

- MTCategoryArchiveLink
  A link to the archive page for this category. This only works if you have enabled `Category` archiving for your weblog; if you have not, you will get an error message when rebuilding your pages.

- MTCategoryDescription
  The description for this category.

- MTCategoryCount
  The number of entries in this category.

- MTCategoryTrackbackLink
  If this category has been set to Accept incoming pings, the TrackBack ping URL that can be used to ping the category. This tag can be used in any category context (category archive or inside `<MTCategories>`), or you can specify the category whose TrackBack link you want using the category attribute. For example:

      <$MTCategoryTrackbackLink category="Foo Bar"$>

  If you specify the attribute, the tag can be used wherever you want to use it.

## Calendar Display Tags

The following tags can be used to output a calendar display of your entries. The calendar display is not restricted to construction using HTML tables; the tags are sufficiently generic that you could use them to create a calendar in many different forms.

- MTCalendar
  A container tag representing a month-long calendar; the markup between the `<MTCalendar>` and `</MTCalendar>` tags represents a single ``cell'' in the calendar (which is either a day of the month or a blank cell representing a day in a different month).

  This tag takes an optional attribute `month`, which, if present, specifies the desired calendar month and year. If the value of this attribute is the string `this`, the calendar will be created in the surrounding date context; this means that, for example, in an archive template, you can use

      <MTCalendar month="this">
      ...
      </MTCalendar>

  to represent the calendar for the month of the archive currently being viewed. This will work for `Individual`, `Daily`, `Weekly`, and `Monthly` archives, not for `Category` archives.

  If the value of the `month` attribute is `last`, the calendar will be created for the previous month, relative to the current date.

  If you'd like to create a calendar for a specific month, you can use the `month` attribute to specify the exact month and year, in `YYYYMM` format (example: `200112`).

  If the `month` attribute is not provided, the calendar will display the current month.

  If you would like to only display entries from a certain category, you can specify the `category` attribute, giving it the name of the category. For example, this tag:

      <MTCalendar month="200201" category="Foo">
      ...
      </MTCalendar>

  will display all entries from January, 2002 in the category `Foo`.

- MTCalendarDay
  The numeric day of the month (example: `1`). You can use this tag within the `<MTCalendarIfEntries>` and `<MTCalendarIfNoEntries>` containers.

- MTCalendarCellNumber
  The number of the ``cell'' in the calendar; this number starts at `1` for the first cell in the top left corner of the calendar and increases as you move across the calendar horizontally.

  This tag is different than `<$MTCalendarDay$>` (above) in that the latter tag applies only in a non-``blank'' cell (ie. an entry that represents a day in this particular month).

- MTCalendarDate
  The timestamp of each day of the month; accepts the standard `format` attribute. If you only wish to display the numeric day, just use `<$MTCalendarDay$>`; you need only use this tag when you want more date/time information in the display.

- MTCalendarWeekHeader
  A container tag; the markup contained between `<MTCalendarWeekHeader>` and `</MTCalendarWeekHeader>` will be displayed at the start of each week.

- MTCalendarWeekFooter
  A container tag; the markup contained between `<MTCalendarWeekFooter>` and `</MTCalendarWeekFooter>` will be displayed at the end of each week.

- MTCalendarIfBlank
  A container tag; the markup contained between `<MTCalendarIfBlank>` and `</MTCalendarIfBlank>` will be displayed if the cell is a ``blank'' cell--that is, if it does not represent a day in this month.

- MTCalendarIfEntries
  A container tag; the markup contained between `<MTCalendarIfEntries>` and `</MTCalendarIfEntries>` will be displayed if there are any entries from the day represented by this cell. You can use the `<MTEntries>` tag to list all of the entries on that particular day.

  For example:

      <MTCalendarIfEntries>
          Entries from this day:
          <MTEntries>
          <a href="<$MTEntryLink$>"><$MTEntryTitle$></a><br />
          </MTEntries>
      </MTCalendarIfEntries>

- MTCalendarIfNoEntries
  A container tag; the markup contained between `<MTCalendarIfNoEntries>` and `</MTCalendarIfNoEntries>` will be displayed if there are no entries from the day represented by this cell.

- MTCalendarIfToday
  A container tag; the markup contained between `<MTCalendarIfToday>` and `</MTCalendarIfToday>` will be displayed if the day represented by the calendar cell is the current date.

Here is the markup for a fairly standard calendar display; this will display a calendar for the current month.

    <table border="0" cellspacing="4" cellpadding="0" summary="Monthly calendar">
    <caption><$MTDate format="%B %Y"$></caption>
    <tr>
    <th abbr="Sunday" align="center">Sun</th>
    <th abbr="Monday" align="center">Mon</th>
    <th abbr="Tuesday" align="center">Tue</th>
    <th abbr="Wednesday" align="center">Wed</th>
    <th abbr="Thursday" align="center">Thu</th>
    <th abbr="Friday" align="center">Fri</th>
    <th abbr="Saturday" align="center">Sat</th>
    </tr>
    <MTCalendar>
    <MTCalendarWeekHeader><tr></MTCalendarWeekHeader>
    <td <MTCalendarIfToday>bgcolor="#EEEEEE"</MTCalendarIfToday> align="center">
    <MTCalendarIfEntries><MTEntries lastn="1"><a href="<$MTEntryLink$>"><$MTCalendarDay$></a></MTEntries></MTCalendarIfEntries>
    <MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
    <MTCalendarIfBlank>&nbsp;</MTCalendarIfBlank></td>
    <MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
    </MTCalendar>
    </table>

NOTE: the computation of the calendar display is relatively expensive, so if you wish to place the same calendar on every page of your site, it is advisable to create the calendar in an index template, then use server side includes or PHP (or any other dynamic webserver tool) to include that file in each of your pages.

## TrackBack Tags

These are tags related to the TrackBack system.

- MTPings
  A container tag that lists all of the pings either on a certain entry, a certain category, or in your entiree system .

  If used within the context of an entry--for example, in the TrackBack Listing Template--this tag will list all of the TrackBack pings sent to that particular entry.

  If used in a template associated with a category archive, this tag will list all of the TrackBack pings sent to that category.

  If used in any other context, this tag will list all of the TrackBack pings sent to your system (unless provided with the lastn tag--see below).

  Additionally, you can provide this tag with the name of the category whose pings you wish to list using the category attribute:

      <MTPings category="Foo">
      ...
      </MTPings>

  You can also provide this tag with sort_order and lastn attributes, which work the same way that they do with other Movable Type tags. The value of sort_order can be either `ascend` or `descend`. The value of lastn should be a positive integer to list the N most recent TrackBack pings.

  For example, to display the last 15 pings in the category `Foo Bar` on the front page of your weblog, add the following to your Main Index Template:

      <MTPings category="Foo Bar" lastn="15">
      <a href="<$MTPingURL$>"><$MTPingTitle$></a><br />
      </MTPings>

- MTPingID
  The numeric ID of the TrackBack ping.

- MTPingTitle
  The title sent in the TrackBack ping. Generally, this is the title of the remote entry.

- MTPingURL
  The URL sent in the TrackBack ping. Generally, this is the URL of the remote entry.

- MTPingExcerpt
  The excerpt sent in the TrackBack ping.

- MTPingDate
  The date that this TrackBack ping was sent to your site. Like all date tags, this tag takes optional `format` and `language` attributes. See Date Tag Formats for more information.

- MTPingBlogName
  The name of the weblog in which the entry was posted.

- MTPingIP
  The IP address of the host that sent the ping.

- MTPingsSent
  A container tag representing the list of TrackBack pings sent from an entry. These are TrackBack ping URLs, not permalinks.

  For example:

      <MTPingsSent>
      URL: <$MTPingsSentURL$><br />
      </MTPingsSent>

- MTPingsSentURL
  The URL for the ping, to be used within the `<MTPingsSent>` tag.

## Search Results Tags

The following tags can only be used in your search templates.

- MTSearchResults
  A container tag representing the list of results for the search that was performed. Within this container tag, you can use any of the `<$MTEntry*$>` tags, because the entry represented by the search result will be in context. You can also use any `<$MTBlog*$>` tags to access data referring to the weblog in which the particular entry result was found.

  For example:

      <MTSearchResults>
      <MTBlogResultHeader>
      <h2>Results from <$MTBlogName$></h2>
      </MTBlogResultHeader>
      <h3><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>"><$MTEntryTitle$></a></h3>
      <$MTEntryExcerpt$> <$MTEntryEditLink$><br />
      <div class="posted">Posted in <$MTBlogName$> on <$MTEntryDate$></div>
      </div>
      </MTSearchResults>

- MTSearchResultCount
  The number of results found for the search across all of the weblogs searched (that is, not a per-weblog result count).

- MTNoSearchResults
  A container tag whose contents are displayed if a search is performed, but no results are found.

  For example:

      <MTNoSearchResults>
      <h2>Searched for "<$MTSearchString$>"</h2>
      <p>No pages were found containing "<$MTSearchString$>".</p>
      </MTNoSearchResults>

- MTNoSearch
  A container tag whose contents are displayed only if there is no search performed. This is the case if a visitor were to go directly to your mt-search.cgi page in his browser:

      http://YOURDOMAIN.COM/PATH-TO/mt-search.cgi

  Or, in the case of the new comment search, if the visitor went to

      http://YOURDOMAIN.COM/PATH-TO/mt-search.cgi?Type=newcomments&help=1

  A good use for this tag might be to display search instructions, or a more advanced search form.

  For example:

      <MTNoSearch>
      <h2>Instructions</h2>
      <p>... Some search instructions ...</p>
      </MTNoSearch>

- MTBlogResultHeader
  When displaying standard search results (that is, results for searches that are not new comment searches), search results are grouped by the weblog in which the result was found.

  This tag is a container tag whose contents are displayed if the search result in context is the first result in the weblog grouping. This is useful for displaying the name of the weblog, and perhaps a link to the main index for the weblog.

- MTEntryEditLink
  A link to edit the entry represented by the search result, if the user displaying the search results page is logged in to Movable Type and has permission to edit the entry listed.

- MTSearchString
  The HTML-encoded search query.

## Miscellaneous Tags

These are tags which really don't fit in any of the above categories.

- MTElse
  You can use `<MTElse>` tag to supply an ``else'' condition for any conditional tag. That is, generally any tag with `If` in its name (for example, `<MTEntryIfExtended>`). `<MTElse>` is a container tag whose contents will be displayed if the condition is not met. The `<MTElse>` container should be placed within the container of the conditional tag for which it is providing the ``else'' condition.

  Here is an example of usage:

      <MTEntryIfExtended>
      This entry has an extended body.
      <MTElse>
      This entry does not have an extended body.
      </MTElse>
      </MTEntryIfExtended>

- MTIfNonEmpty
  Use the `MTIfNonEmpty` tag to check whether the value of another tag would not be empty. The other tag name should be supplied in the `tag` attribute to this tag. This is a conditional tag, so the markup inside of the tag will be displayed if the condition (a non-empty value for the result of evaluating `tag`) is true.

  For example:

      <MTIfNonEmpty tag="MTEntryAuthorURL">
      The author's homepage URL is <$MTEntryAuthorURL$>.
      </MTIfNonEmpty>

- MTInclude
  Use the `MTInclude` tag to include either a template module (see Template Modules, above, in TEMPLATES), or an external file, into another template. `<MTInclude>` takes the following attributes:
  - module
    The name of a template module as defined in your template listings. For example, if you have a common chunk of HTML that you use as a header in all of your templates, and you wish to manage this chunk through Movable Type, you can pull that chunk into a template module, name it `Header`, then include it using `<MTInclude>`:

        <$MTInclude module="Header"$>

  - file
    The path to an external file to include in your template. The path to the file can be a full filesystem path, or it can be the name of a file in either your `Local Site Path` directory, or your `Local Archive Path` directory. For example, if the file foo.html exists in your local site path directory, you can include it in a template like this:

        <$MTInclude file="foo.html"$>

    This file is included in your template when the page is rebuilt; note that this behavior should not be confused with server side includes, which will include the external file every time the webserver serves a request for your page. After making changes to an external file that you are including through `<MTInclude>`, then, note that you will need to rebuild your pages to include the modified version of the page.

- MTLink
  You can use the `<MTLink>` tag to automatically generate the URL for an index template or an entry in the system. `<MTLink>` takes the following attributes:
  - template
    The name of an index template as defined in your template listings. For example, if you'd like to generate a link to an about page template that you have called `About Page`, you could use:

        <a href="<$MTLink template="About Page"$>">My About Page</a>

  - entry_id
    The numeric ID of an entry that you'd like to link to. For example:

        <a href="<$MTLink entry_id="562"$>">Link to a certain entry</a>

- MTDate
  A standard date/time tag representing the current date and time at which the page is being rebuilt. You can use this for a `Last updated at` slug, for example:

      This page last updated at <$MTDate format="%B %d, %Y %I:%M %p"$>.

- MTGoogleSearch
  Uses the Google API to obtain a list of search results for a particular query, or to list a set of pages that are similar to a particular page.

  This tag can be given the following attributes:

  - query
    The search query.

  - related
    Tells Google to return pages similar to a certain page; the value can be either a URL, in which case the pages will be similar to that URL, or `1`, in which case the pages will be similar to your page (assuming that you have set your Site URL to the URL for your main page). See below for an example.

  - title
    If you use the attribute title=``1'', the query sent to Google will be the title of the current entry.

  - excerpt
    If you use the attribute excerpt=``1'', the query sent to Google will be the excerpt of the current entry.

  - keywords
    If you use the attribute keywords=``1'', the query sent to Google will be the keywords of the current entry.

  - results
    The number of results to return; Google will currently not return more than 10 results per query, so the maximum (currently) is `10`.

  For example, to list the top 5 search results for the query `movable type`:

      <MTGoogleSearch query="movable type" results="5">
      <a href="<$MTGoogleSearchResult property="URL"$>"><$MTGoogleSearchResult property="title"$></a><br />
      </MTGoogleSearch>

  Or, for a list of pages similar to your page:

      <MTGoogleSearch related="1">
      <a href="<$MTGoogleSearchResult property="URL"$>"><$MTGoogleSearchResult property="title"$></a><br />
      </MTGoogleSearch>

  Note that query, related, title, and excerpt are all mutually exclusive.

  Also note that if you use the Google Search tag in your Individual Archive Template, the list of search results will be generated whenever you save an entry. This can slow down the rebuilding process, and if you post quite a bit, or get a lot of comments on your site, you may exceed the number of queries per day that you are allowed by Google.

  NOTE: usage of this tag requires that you have obtained a Google API key and pasted it into your weblog configuration, and that you have installed the SOAP::Lite and LWP::UserAgent modules (run mt-check.cgi to determine if you have these modules installed).

- MTGoogleSearchResult
  An individual result of a Google API search (see `<MTGoogleSearch>`, above).

  Takes one attribute, property, which specifies the field of the search result to be displayed (for example: title, URL, summary, etc.). The default property is `title`.

  Valid values for property include: `summary`, `URL`, `snippet`, and `title`.

- MTSetVar
  Sets the value of a variable--you define the name of the variable using the `name` attribute, and the value using the `value` attribute. You can then retrieve the value of the variable using the tag `<MTGetVar>` (below).

- MTGetVar
  Gets the value of a variable and replaces the tag with the value of that variable; the name of the variable should be supplied in the `name` attribute to this tag. For example

  For example, you can set the value of a variable `foo` in an outer template:

      <MTSetVar name="foo" value="bar">

  and then, in an included template module, grab the value of that variable:

      <MTGetVar name="foo">

- MTCGIPath
  The URL path to the directory containing the Movable Type CGI scripts. This tag is substituted with the value of the `CGIPath` configuration file line (set during installation; see the Installation Instructions). `MTCGIPath` makes linking to Movable Type CGI scripts--such as mt-comments.cgi and mt-add-notify.cgi--very simple; instead of having to type in the URL to these CGI scripts every time you use them in your templates, instead you should just use this tag. For example, when creating a form for posting comments:

      <form method="post" action="<$MTCGIPath$><$MTCommentScript$>">

- MTCommentScript
  The setting for CommentScript in your mt.cfg file; the default value is mt-comments.cgi.

- MTTrackbackScript
  The setting for TrackbackScript in your mt.cfg file; the default value is mt-tb.cgi.

- MTStaticWebPath
  The value of the StaticWebPath setting as set in mt.cfg.

- MTImageURL
  The absolute URL of the image that was uploaded, for use in the `Uploaded Image Popup Template`.

- MTImageWidth
  The width of the image that was uploaded, for use in the `Uploaded Image Popup Template`.

- MTImageHeight
  The height of the image that was uploaded, for use in the `Uploaded Image Popup Template`.

- MTErrorMessage
  This tag can be used only in the `Comment Error Template`; it will be replaced with the text of the error that occurred in the comment submission process (for example, an invalid or missing email address).

- MTVersion
  The version of MT that you are running. Example: `2.0`.

- MTPublishCharset
  The value of the PublishCharset setting in mt.cfg; if not set, defaults to `iso-8859-1`.

## Global Tag Attributes

Global tag attributes can be used in any variable substitution tag (a tag that is replaced with a value--in contrast to a container tag, which ``contains'' a set of markup and other tags). However, this does not mean that they would necessarily make sense when used in any tag; it is up to the user to determine when using a particular tag attribute might not make practical sense.

You should use a global attribute just as you would use a tag-specific attribute: as a `name="value"` pair within the tag. For example:

    <$MTEntryExcerpt encode_html="1"$>

This will be replaced with an HTML-encoded version of the excerpt.

Here is a list of the global tag attributes:

- filters
  Lists a set of Text Formatting filters that will be applied to the tag value. The filter names should be the short names that uniquely identify the filters, not the long labels shown in the Text Formatting options. You can separate filter names with commas (`,`). If you specify multiple filters, they will be executed in the order in which you list them. For example, if you have defined a filter with the short name wiki, which runs a string through the Text::WikiFormat CPAN module, you could do this:

      <$MTEntryTitle filters="wiki"$>

  to turn a title of `''This is a title''` into `<em>This is a title</em>`.

- encode_html
  When set to `1`, HTML-encodes the tag value. For example, if the value of the tag without this attribute were `Foo & Bar -> Baz`, the HTML-encoded version would be `Foo &amp; Bar -&gt; Baz`.

  Example usage:

      <$MTEntryExcerpt encode_html="1"$>

- encode_xml
  When set to `1`, encodes into entities any characters that XML requires to be encoded. These are: `&`, ``, `<`, and `>`. For example, if the value of the tag without this attribute were `Foo & Bar -> Baz`, the XML-encoded version would be `Foo &amp; Bar -&gt; Baz`.

  Example usage (in an RSS template);

      <item>
          <title><$MTEntryTitle encode_xml="1"$></title>

  Note: The difference between this and encode_html is that the latter encodes a much wider set of special characters into HTML entities, if you have the HTML::Entities module installed and you have not turned on the NoHTMLEntities option in mt.cfg.

- encode_js
  When set to `1`, encodes the tag value into a format suitable for usage in a Javascript string value. For example, if the value of the tag without this attribute were `Foo "Bar" Baz's 1/2 Quux`, the encoded version would be `Foo \"Bar\" Baz\'s 1\/2 Quux`.

  Example usage:

      <script language="javascript">
      var str = '<$MTEntryTitle encode_js="1"$>';
      </script>

- encode_php
  Encodes the tag value into a format suitable for usage in one of three PHP string values: single-quote, double-quote, or here document. The value of this tag attribute should be either `q` (single-quote), `qq` (double-quote), or `heredoc` (here document--note that `here` will also work for a here document).

  Example `q` usage:

      <?php
      $str = '<$MTEntryTitle encode_php="q"$>'
      ?>

  Example `heredoc` usage:

      <?php
      $str = <<<HERE
      <$MTEntryBody encode_php="heredoc"$>
      HERE;
      ?>

- encode_url
  Encodes the tag value into a format suitable for usage in a URL. This involves encoding non-alphanumeric characters into their hex equivalents. For example, the string `foo bar` would be transformed into `foo%20bar`.

  Example usage:

      <a href="/search?q=<$MTEntryTitle encode_url="1"$>">Search</a>

  (Thanks to Scott Andrew LePera for providing the original example on which this is based.)

- decode_html
  When set to `1`, decodes all HTML entities in the tag value. For example, if the value of the tag without this attribute were `foo&lt;br&gt;`, the version with decoded HTML entities would be `foo<br>`.

  Example usage:

      <$MTEntryTitle decode_html="1"$>

- decode_xml
  When set to `1`, decodes all XML entities in the tag value. For example, if the value of the tag without this attribute were `foo&lt;br&gt;`, the version with decoded HTML entities would be `foo<br>`.

  Example usage:

      <$MTEntryTitle decode_xml="1"$>

- remove_html
  When set to `1`, strips all HTML tags from the tag value. For example, if the value of the tag without this attribute were `Foo<br> Bar`, the version without HTML tags would be `Foo Bar`.

  Example usage:

      <$MTEntryTitle remove_html="1"$>

- dirify
  When set to `1`, ``dirifies'' the tag value. This means that the value of the tag is made suitable for usage in a file or directory name: the value is converted to lower case, HTML tags and entities are stripped, strange characters are stripped (where strange is defined as not included in the following set: alphanumeric characters, underscore (`_`), and whitespace), and whitespace is then converted to underscores (`_`).

  dirify also converts certain high-ASCII characters (accented characters, etc) to their low-ASCII characters, meaning that something like `crudité` will be converted to `crudite`.

  For example, if the value of the tag without this attribute were `Foo "Baz" is<br> Bar!`, the dirified version would be `foo_baz_is_bar`.

  Example usage:

      <$MTArchiveCategory dirify="1"$>

- upper_case
  Upper-cases the tag value.

  Example usage:

      <$MTEntryTitle upper_case="1"$>

- lower_case
  Lower-cases the tag value.

  Example usage:

      <$MTArchiveDate format="%B" lower_case="1"$>

- trim_to
  Trims the tag value to the first N characters, where N is specified as the value of the attribute.

  Example usage:

      <$MTEntryTitle trim_to="15"$>

  The above tag will only display the first `15` characters in the entry title.

- space_pad
  Pads the tag value with spaces so that the total length is N characters, where N is specified as the value of the attribute.

  Example usage:

      <$MTCalendarDay space_pad="3"$>

  The above tag will pad the value `3` to ```3`''.

- zero_pad
  Pads the tag value with zeros so that the total length is N characters, where N is specified as the value of the attribute.

  Example usage:

      <$MTCalendarDay zero_pad="5"$>

  The above tag will pad the value `8` to `00008`.

- sprintf
  A general purpose sprintf-formatter. The value of the attribute should be the format string; the tag value will be passed in as the argument to sprintf. For example, zero_pad could be implemented as

      <$MTCalendarDay sprintf="%05s"$>

- sanitize
  Runs the sanitize filter on the text in question. If the value of the attribute is `1`, the default sanitize spec--for the weblog, or for the global settings--is used. If the value is `0`, sanitizing will be turned off for this tag. If the value is anything else, it will be treated as the sanitize spec to be used.

  Example usage:

      <$MTEntryBody sanitize="a href"$>

  This would strip all HTML tags except for `<a>` (with the `href` attribute) from the entry body.

## Date Tag Formats

Movable Type uses standard `strftime` format strings to describe dates and times. (However, note that `strftime` itself is not actually used to perform the formatting.) In any date tag, you should use the `format` attribute to specify the format string, like this:

    <$MTDate format="%B %e, %Y %I:%M %p"$>

The above format is actually the default format for English date formatting, and creates a date looking like this:

    September 20, 2001 11:44 PM

The language used in weekday names, month names, and AM/PM specifiers can be chosen in the Weblog Configuration as `Language for date display`. The default language used is `English`.

You can override the default language setting by using the `language` attribute to specify the language; this will apply only for the particular date string that you are formatting. Here is the list of available language tags: `cz`, `dk`, `nl`, `en`, `fr`, `de`, `is`, `jp`, `it`, `no`, `pl`, `pt`, `si`, `es`, `fi`, `se`.

Here is a list of the format specifiers.

- %a
  The abbreviated weekday name. Example: `Thu`.

- %A
  The full weekday name. Example: `Thursday`.

- %b
  The abbreviated month name. Example: `Sep`.

- %B
  The full month name. Example: `September`.

- %d
  The day of the month, two digits, padded with a `0` if necessary. Example: `09`.

- %e
  The day of the month, padded with a space if necessary. Example: `9`.

- %H
  The hour, using a 24-hour clock (military time), two digits, padded with a `0` if necessary. Example: `16`.

- %I
  The hour, using a 12-hour clock, two digits, padded with a `0` if necessary. Example: `04`.

- %j
  The day of the year, three digits, padded with `0`s if necessary. Example: `056`.

- %k
  The hour, using a 24-hour clock (military time), two digits, padded with a space if necessary. Example: `9`.

- %l
  The hour, using a 12-hour clock, two digits, padded with a space if necessary. Example: `4`.

- %m
  The month, two digits, padded with a `0` if necessary. Example: `09`.

- %M
  The minute, two digits, padded with a `0` if necessary. Example: `02`.

- %p
  Either `AM` or `PM`.

- %S
  The second, two digits, padded with a `0` if necessary. Example: `04`.

- %x
  The language-aware date representation. For most languages, this is just the same as %B %e, %Y. Example: `September 6, 2002`.

- %X
  The language-aware time representation. For most languages, this is just the same as %I:%M %p. Example: `4:31 PM`.

- %y
  The year, two digits, padded with a `0` if necessary. Example: `01`.

- %Y
  The year, four digits. Example: `2001`.

NOTE: As of version 2.0 of Movable Type, `%Z` is no longer supported. If you want the timezone, take a look at the `<$MTBlogTimezone$>` tag.

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