« Santa Barbara | Main | 2003 Books So Far »

Process Entry Tags Plugin

Several days ago, I tried to put together some macros to format tables of photos in a clean and easy way. It would seem cleanest to implement that functionality as normal Movable Type tags, and use a text processing filter to expand those tags into the proper HTML code. Due to technical problems, I gave up on processing XML. Now, though, thanks to an example from Kalsey Consulting's Process Tags plugin, I was able to get the Movable Type template processor to do the work.

The root of the problem is that template tags are not parsed in MT entries. There is a good reason for this: Entries are intended for normal users, which may not be familiar with or care to bother with XML representations of data. However, there are some power users that might desire this functionality.

In my case, I wanted to simplify the uploading, scaling, and presentation of digital photos within an entry. Many photoblog templates are intended to show each photo within its own entry, but I wanted to associate several photos together, to better tell a particular story. There are some good plugins, such as Brad Choate's EmbedImage that already accomplish some of the functionality. But I couldn't find anything that brings multiple images together in an entry.

There are a number of ways of processing tags within an entry. Brad Choate's MTMacros plugin can be used to define macros at the archive template level, and have them applied within the entry. This is intended to allow more than just MT tags: The blogger can define any kind of text to be macro-expanded. Kalsey Consulting's Process Tags plugin is closer to the functionality that I needed, in that it used the MT builder to process the entry for any tags. But both of those require changes to the templates, which doesn't seem quite right to me. The choice to apply or not apply MT tag should be made on an entry-by-entry basis. A text filter (new to MT 2.6) seems a better place for such code.

So, with a nod to the Kalsey code, I present Process Entry Tags, a text filter plugin. It is surprisingly short, which makes sense, because all it has to do is call up the existing MT builder. It has no external dependencies, other than Movable Type (version 2.6) itself.

The major strength of this approach is that it puts the decision about whether or not to process MT tags into the entry itself. Some authors on a particular site may choose to use it, while others may not. Any legal MT tag can be used, without having to change any templates.

There are some drawbacks, though. I could imagine that some people would like to use other text filter plugins at the same time. For example, I might use my (forthcoming) phototable plugin to put together a nice layout of graphics and text in an entry, but still want to process the text using the TikiText processor to nicely format the text. This cannot be done currently, as only one text filter can be selected.

Let me know if you find it useful.

Ads

TrackBack

TrackBack URL for this entry:
http://www.borlik.net/cgi-bin/blog/mt-tb.cgi/30

Comments

I've been looking high and low for a option to parse MT tags in my templates!

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)