Templating Tricks: Movable Type to Rich Text

A few years ago Six Apart's Anil Dash posted this article about using Movable Type to generate a Word document of your blog or part of it. It uses WordML to generate a Microsoft Word 2003 formatted documents. This is fine and dandy if you have Word, but what if you don't?

As Anil's post shows, it is very easy for Movable Type to generate any document type that you know the specification, so lets give it a go with another ubiquitous file format; Rich Text Format, the full specification can be downloaded from Microsoft

Below is a simple template which outputs a Rich Text Formatted file showing the last 5 entries from your blog.

{\rtf
{\b <MTBlogName>}
\par
<MTEntries lastn="1">
Author: <MTEntryAuthorNickname encode_xml="1">
\par
Modified: <MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ">
\par
</MTEntries>
\par
\par    
<MTEntries lastn="5">
{\b <MTEntryTitle>}
\par
<MTEntryBody  convert_breaks="0" remove_html="1">
\par
\par
</MTEntries>
}

you need to create a new custom index template and paste the above code in. Set the output file to recent.rtf. When this template is published it generates a rich text format file at your blog root that contains the last 5 entries in your blog.

This technique can be used for a number of different formats; OOXML, LaTex or OpenDocument for example. It can also be expanded to include a list of recent comments or limit the report to specific tags, categories or keywords.

Leave a comment

Gallery

Recent Entries

  • Creating a Clickable Header in Movable Type

    A question that comes up every so often on the Movable Type message boards is how to create a clickable banner that links back to...

  • So You Want To Write A Movable Type Plugin?

    One of the great things about Movable Type is it's flexibility. Behind the scenes is a powerful system that can be used to expand the...

  • Learning to Share

    Today I have added functionality to this site and to Darren Kenny Paralympic Cyclist that makes it easier for visitors to share the love and...

  • What has been happening

    The last week or so I have spent time on upgrading by brother's site to run on Movable Type 4.2. The previous site was still...

  • Almost Recent Entries

    There are some things about blogging that just doesn't make sense, take recent entries as an example. On the front page you have maybe your...

Close