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:
MTEntriesMTEntriesis 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
lastnor 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
FooandBaryou 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
lastnand other attributes to limit the display to a certain number.days="N"Display all posts less than N days old.
The
daysattribute 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
MTEntriestag. 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_byattribute 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
lastnandcategoryattributes toMTEntries. 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 theauthorattribute.<MTEntries category="Fun" author="Me" lastn="10"> ... </MTEntries>This template markup would display the last 10 entries by author "Me" in the category "Fun."
MTEntryTitleThe title of the entry.
MTEntryPermalinkThe 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.
MTEntryExcerptThe excerpt of the entry. If one was not defined the first 20 words of the body will be used followed by an ellipsis.
MTEntryBodyThe content of the entry body with any text formatting applied.
MTEntryMoreThe contents of the extended entry with any text formatting applied.
MTEntryDateThe published-on timestamp of the entry. Optional
formatandlanguageattributes 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.



