MT-Ellipsis: A Movable Type Filter

Current version is 1.0.1.0 released on 2005-09-04

Contents

What This Filter Does

This filter is used to trim and add an ellipsis … to a given string published from Movable Type. If the string is less than the given length, the string remains unchanged.

I created this filter because I use a list of recent comments on my main blog index page and I wanted to trim down the entry body to a number of characters and add an ellipsis to the end. For those entries that are less than the desired length, no changes were desired.

Requirements

  • This plugin works with Movable Type version 2.x and 3.x.
  • Perl version 5.8.5 or higher. This is what I use. It may work on lower versions. Let me know if it does and I will lower this.
  • You must have the Perl module, Storable, installed.
  • This plugin will only work in static (not dynamic) templates.

Installation Instructions

  1. Download the latest version of the filter.
  2. Unzip the contents of the file.
  3. Copy the file Ellipsis.pl to your Movable Type “plugins” directory. (If you don’t have a plugins directory, create a plugins directory in the same directory where your mt.cgi file is located. Then upload Ellipsis.pl into the newly created plugins directory.)
  4. Give me some credit. You have many choices. Do one or all! 1) Add a trackback link to this page on your page. 2) Donate so that I continue to enhance this filter.

How To Use The Tags

This plugin will only work in static (not dynamic) templates.

  • ellipsis
    Add this filter to any Movable Type tag as a parameter. The attribute value should be set to the length that you want to trim the string to.

Frequently Asked Questions

  • Q: This plugin (and others) don’t seem to be working on my server. Why?
    A: Internally, Movable Type requires some Perl modules to be installed for plugins to work. Some servers do not have these modules installed by default. Please run mt-check.cgi on your server to find out what you are missing.

Examples

1. In this simple example, we add the ellipsis filter to a comment string to chop the comment body down to seventy characters.

<$MTCommentBody convert_breaks="0" remove_html="1" ellipsis="70"$>

Donate

If you enjoy using this filter and/or would like to see it enhanced, please donate a buck or two…or fifty. I will use the money to buy my wife dinner so she lets me keep working on this stuff for free and does not complain.

License

This software is licensed under the CC-GNU LGPL.

CC-GNU LGPL

Download

Download the current version from the link below. Past versions are not archived.

Version History

1.0.1.0 — 2005-09-04
  • Updated plugin info to take advantage of MT 3.2 enhancements.
1.0.0.1 — 2004-12-10
  • Fixed bug where plugin reported error in MT-Medic.
1.0.0.0 — 2004-05-29
  • Made compatible with Movable Type 3.0.
0.10 — 2004-01-11
  • Works for me.

Contact

For questions, suggestions, bug reports, and anything else related to this filter, please e-mail brandon@fuller.name or leave a comment.

Updated: 2009-11-25 at 10:51 MST in Hacks
Tags: movabletype

9 Comments

chris

a suggestion: use "…" instead of "..." (view source)

chris

err you know what I mean--do what SmartyPants does

Brandon Fuller

I thought about doing that but I decided not to. I figured if you like using the SmartyPants way you can just apply SmartyPants to your tag also because you probably already have it installed. If not you get normal characters that you can cut and paste, etc.

Kekawaka

Just started playing with this tag, and noticed this: if the string gets trimmed after a formatting start tag (e.g. blockquote or bold), but before the accompanying end tag, the result is screwed up formatting for the rest of the page. I imagine that's a tough one to work around? - cheers

Brandon Fuller

Yeah, I noticed that a few days ago. I am not sure if its worth the effort right now. It doesn't happen to me that often since I only use it for comments.

Jonathan Horak

Kekawaka, Brandon: If it helps, you can use remove_html="1" to strip out anything that could break page formatting. I have that going on at my dotcomments (http://www.anotherpointless.com/ments/ page.

Plugin working like a charm, by the way. Thanks Brandon!

Patrick

Hello Brandon,

This plugin is a great idea. Just installed it and wondered if there's a tweak. If a text string gets trimmed by your plugin, it adds the ellipsis to the end. How can I get the plugin to back up three characters and then put in the three periods?

Example:
1) string is 26 chars long, left untouched.
2) string is 45 chars long, trimmed to 23, 3 periods added to end, totalling 26 chars.

THANKS!

Brandon Fuller

That isn't the way I designed it. However, I guess you could just add 3 more to the number of characters that you want to remove.

sftco

this hack works after spending sometime on it.crish suggesion is good i do support.

Leave a comment

(Required)
(Required, Hidden, Gravatar - Click to upload your own photo!)
(Optional)