The Movable Type User Manual

NOTE: This documentation is for Movable Type 3.2. If you are using a newer version, please see the documentation for Movable type 3.3x or Movable Type Enterprise.

« Customizing the Edit Entry Screen | Up | Making posts quickly from your browser »

Chapter 4: Posting Entries

Displaying Entries

Problem

You need to display entry data in your published pages.

Solutions

Use the template tags that are prefixed with MTEntry.

Discussion

Entry tags can be used to display the contents of an entry and its related information. These tags can be used in MTArchiveList or MTEntries tag contexts. Entry tags may also be used anywhere in a Individual Archive template.

Here are some of the more common Entry tags used in templates:

  • MTEntries

    MTEntries is the most powerful and adaptive template tag in Movable Type. It is a container tag representing a list of entries from your weblog. The actual list of posts can be configured using the optional attributes to this tag. The default behavior is set according to the Entries to Display and Entry Order controls in the General Settings. These settings can be overridden with the use of these optional attributes.

    • lastn="N"

      Display the last N posts to this weblog, where N is an integer greater than 0.

    • offset="M"

      When used with lastn, 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).

      This attribute is only recognized when used with lastn; otherwise it is ignored.

    • category="category_name"

      Display all posts from the category labeled category name. Depending on the weblog, this could be a long list of entries. Use lastn or other attributes to further limit the list.

      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. This logic is limited though. You can only include one or the other, so you cannot say "Foo AND Bar OR Baz." You can only say "Foo AND Bar AND ..." or "Foo OR Bar OR ..."

      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 could be a long list of entries, and you may want to use lastn and other attributes to limit the display to a certain number.

    • days="N"

      Display all posts less than N days old.

      The days attribute can only be used by itself. If it is used with any other attribute it will be ignored.

    • recently_commented_on="N"

      Display the N most recently commented-on entries. Each entry will appear in the list only once no matter how many comments each has. So if 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 Default Entry Display Settings sort order. Valid values are "ascend" and "descend."

      In this context, "ascend" and "descend" do not relate only to chronological order. This attribute can be used with sort_by attribute to sort other fields alphabetically.

      The default value is "descend."

    • sort_by="field name"

      Sort by a field other than the Authored On Date of the entry. Valid values are "title," "status," "modified_on," "author_id," or "excerpt."

      The most common use of this attribute might be to alphabetize your entries rather than display them chronologically. Suppose you want tp display a list of posts alphabetically according to title. You would use this markup:

       <MTEntries sort_by="title" sort_order="ascend">
       ...
       </MTEntries>

    You can apply these combined attributes to entry filter lists in numerous ways. For example, you could supply both lastn and category attributes to MTEntries. This does just what you would expect: it displays the last N entries in a particular category. If you wished to filter that further using author name, you could add the author attribute.

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

    This template markup would display the last 10 entries by author "Me" in the category "Fun."

  • MTEntryTitle

    The title of the entry.

  • MTEntryPermalink

    The absolute URL pointing to the archive page containing the entry. If Individual Entry archives are not in use, an anchor with the entry's ID will be appended.

  • MTEntryExcerpt

    The excerpt of the entry. If one was not defined the first 20 words of the body will be used followed by an ellipsis.

  • MTEntryBody

    The content of the entry body with any text formatting applied.

  • MTEntryMore

    The contents of the extended entry with any text formatting applied.

  • MTEntryDate

    The published-on timestamp of the entry. Optional format and language attributes can be applied. See Appendix C for more on date formatting options.

For an exhaustive list of Entry tags refer to "Entries" in Appendix A.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or question. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.