MTML Code in Entries or Pages

| No Comments

You want a page with a title and a few paragraphs… but you also want a list of entries as a part of the page. How to do it?

You can use the mteval global modifier, but in the note I added there due to the way MT is optimized to publish, using the mteval global modifier isn’t really an option for most cases.

But there is a better way. The concept is to use an index template but to build the content of the template by combining content from a page and from entries.

Here’s how to create a page for entries tagged as events:

  1. Create a page titled “Events”.

    Add the body text “These are our events”.

    Add the tag “@eventpage”.

  2. Create a few entries with sample event info and add the tag “event”.

  3. Create a new index template called “Events” and set the output file as events.html.

    In the body of the template add this code to list the most recent 10 events tagged with the private tag “@event”:

    <mt:Pages tag="@eventpage" lastn="1">
        <h1><$mt:EntryTitle$></h1>
        <$mt:EntryBody$>
    </mt:Pages>
    <ul>
    <mt:Entries tag="event" lastn="10">
        <li><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></li>
    </mt:Entries>
    </ul>
    
  4. Save the index template… and then publish the index template.

That’s it. =)

Leave a comment