Not a developer? Go to MovableType.com

Documentation

Archive Template Variables

During the template modularization in MT4 we realized that we could combine the Date-Based Archive and the Category Archive templates because they essentially provided the same functionality, they output a list of entries, and thus the Entry Listing template was created.

In addition to category and date-based archives we added the ability to create author archives. To make sure that author and category archives didn’t get too big, we updated each of them to only show the most recent entries (of course this default behaviour can easily be changed).

Because the author and category archives now only displayed recent entries we needed a way to display the older entries. To do this we combined the date-based template with author and category to offer the following template mappings:

Movable Type 4 Template Mappings

  • Daily
  • Weekly
  • Monthly
  • Yearly
  • Category

New in Movable Type 4.0

  • Category-Daily
  • Category-Weekly
  • Category-Monthly
  • Category-Yearly
  • Author
  • Author-Daily
  • Author-Weekly
  • Author-Monthly
  • Author-Yearly

One Template, Many Mappings

Although you can have a separate template for each archive mapping (e.g. for category archives, monthly archives, author-monthly archives, etc) it’s far more maintainable, if there’s little differentiation between them, to use a single template — the Entry Listing template — with portions of the page conditionalized to display content differentially based on the archive type being produced

Movable Type makes this possible by populating one or more of a standard set of variables for each page which indicate what type of page is being published. These variables (which are listed and documented in full below) can be used as conditional flags (i.e. in mt:If or mt:Unless blocks) to control any portion of the published page.

For example, let’s say you are publishing the following archive types with the Entry Listing template:

  • monthly
  • category
  • category-monthly
  • author
  • author-monthly

Your goal is to place a link to the home page of your site on all the pages that are date-based: monthly, category-monthly, and author-monthly. Here’s the code you would place in the entry listing template:

<mt:if name="datebased_archive">
    <a href="http://www.example.com">home page</a>
</mt:if>

If you want add a link for category-monthly and author-monthly you could do this:

<mt:if name="category_monthly_archive">
    <$mt:setvar name="foo" value="1"$>
<mt:else name="author_monthly_archive">
    <$mt:setvar name="foo" value="1"$>
</mt:if>

<mt:if name="foo">
    <a href="http://www.example.com">home page</a>
</mt:if>

So that’s basically how it works. Should you wish to dig deeper, the archive variables are set in $MT_DIR/lib/MT/WeblogPublisher.pm.

Below is a summary of the auto-created variables in archive and system templates, as well as the manually created variables in system and index templates.

Template Variables (table)

This table describes the relationship between Archive Types (across top) and Archive Template Variables (down the sides).

  • Use the scrollbar at the bottom to see all the Archive Types.
  • Click a cell of the table to mark it.
variable Entry Page Daily Weekly Monthly Yearly Category Category-Daily Category-Weekly Category-Monthly Category-Yearly Author Author-Daily Author-Weekly Author-Monthly Author-Yearly variable
archive_class entry-archive page-archive datebased-daily-archive datebased-weekly-archive datebased-monthly-archive datebased-yearly-archive category-archive category-daily-archive category-weekly-archive category-monthly-archive category-yearly-archive author-archive author-daily-archive author-weekly-archive author-monthly-archive author-yearly-archive archive_class
entry_archive 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 entry_archive
page_archive 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 page_archive
archive_template 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 archive_template
preview_template 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 preview_template
entry_template 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 entry_template
page_template 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 page_template
feedback_template 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 feedback_template
datebased_archive 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 datebased_archive
datebased_only 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 datebased_only
datebased_daily_archive 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 datebased_daily_archive
datebased_weekly_archive 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 datebased_weekly_archive
datebased_monthly_archive 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 datebased_monthly_archive
datebased_yearly_archive 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 datebased_yearly_archive
category_archive 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 category_archive
category_daily_archive 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 category_daily_archive
category_weekly_archive 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 category_weekly_archive
category_monthly_archive 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 category_monthly_archive
category_yearly_archive 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 category_yearly_archive
author_archive 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 author_archive
author_daily_archive 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 author_daily_archive
author_weekly_archive 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 author_weekly_archive
author_monthly_archive 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 author_monthly_archive
author_yearly_archive 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 author_yearly_archive

 

Template Variables (list)

All Archives

  • archive_template: 1
  • preview_template: 1 (This var is true when a template is being displayed in preview mode.)

preview_template is useful for situations when rich media ads are embedded in Movable Type templates that interact badly with the template, entry, and page preview modes. Poorly-behaved rich media ads can otherwise make working within the entry, page, and template editors in the CMS difficult.

Depending on what is intended, you can use mt:If var or mt:Unless var tags to selectively display or hide markup.

Examples:

<mt:If var="preview_template">
 <p><strong>This is entry preview mode!</strong></p>
</mt:If>

<mt:Unless var="preview_template">
 <p><strong>This is not entry preview mode!</strong></p>
</mt:Unless>

Entry & Page Archives

Note: The “Entry” archive type is referred to as “Individual” due to legacy usage.

Individual

  • archive_class: entry-archive
  • entry_archive: 1 (this var added in 4.2)
  • entry_template: 1
  • feedback_template: 1

Page

  • archive_class: page-archive
  • page_archive: 1
  • page_template: 1
  • feedback_template: 1

Datebased Archives

Daily

  • archive_class: datebased-daily-archive
  • datebased_archive: 1
  • datebased_only_archive: 1
  • datebased_daily_archive: 1

Weekly

  • archive_class: datebased-weekly-archive
  • datebased_archive: 1
  • datebased_only_archive: 1
  • datebased_weekly_archive: 1

Monthly

  • archive_class: datebased-monthly-archive
  • datebased_archive: 1
  • datebased_only_archive: 1
  • datebased_monthly_archive: 1
  • module_monthly_archives: 1 (Deprecated in MT4.1)

Yearly

  • archive_class: datebased-yearly-archive
  • datebased_archive: 1
  • datebased_only_archive: 1
  • datebased_yearly_archive: 1
  • module_yearly_archives: 1 (Deprecated in MT4.1)

Category Archives

Category

  • archive_class: category-archive
  • category_archive: 1
  • datebased_archive: 0
  • module_category-monthly_archives: 1 (Deprecated in MT4.1)
  • module_category_archives: 1 (Deprecated in MT4.1)

Category-Daily

  • archive_class: category-daily-archive
  • category_archive: 1
  • datebased_archive: 1
  • category_daily_archive: 1

Category-Weekly

  • archive_class: category-weekly-archive
  • category_archive: 1
  • datebased_archive: 1
  • category_weekly_archive: 1

Category-Monthly

  • archive_class: category-monthly-archive
  • category_archive: 1
  • datebased_archive: 1
  • category_monthly_archive: 1
  • module_category-monthly_archives: 1 (Deprecated in MT4.1)
  • module_category_archives: 1 (Deprecated in MT4.1)

Category-Yearly

  • archive_class: category-yearly-archive
  • category_archive: 1
  • datebased_archive: 1
  • category_yearly_archive: 1

Author Archives

Author

  • archive_class: author-archive
  • author_archive: 1
  • datebased_archive: 0
  • module_author-monthly_archives: 1 (Deprecated in MT4.1)
  • module_author_archives: 1 (Deprecated in MT4.1)

Author-Daily

  • archive_class: author-daily-archive
  • author_archive: 1
  • datebased_archive: 1
  • author_daily_archive: 1

Author-Weekly

  • archive_class: author-weekly-archive
  • author_archive: 1
  • datebased_archive: 1
  • author_weekly_archive: 1

Author-Monthly

  • archive_class: author-monthly-archive
  • author_archive: 1
  • datebased_archive: 1
  • author_monthly_archive: 1
  • module_author-monthly_archives: 1 (Deprecated in MT4.1)
  • module_author_archives: 1 (Deprecated in MT4.1)

Author-Yearly

  • archive_class: author-yearly-archive
  • author_archive: 1
  • datebased_archive: 1
  • author_yearly_archive: 1

Index Templates

Main Index

  • main_index: 1

Archive Index

  • archive_index: 1

System Templates

Comment Response

  • system_template: 1 (this var added in 4.2)
  • comment_response_template: 1 (this var added in 4.2)
  • body_class has three variations based upon response type:
    • mt-comment-confirmation
    • mt-comment-pending
    • mt-comment-error

Comment Preview

  • system_template: 1 (this var added in 4.2)
  • comment_preview_template: 1 (this var added in 4.2)
  • body_class: mt-comment-preview

Dynamic Error

  • system_template: 1 (this var added in 4.2)
  • dynamic_error_template: 1
  • body_class: mt-dynamic-error

Search Results

  • system_template: 1 (this var added in 4.2)
  • search_template: 1
  • search_results: 1
  • body_class: mt-search-results
Back