« pair Networks | Main | CGI.pm bug »

MTEntryExcerpt

The Movable Type MTEntryExcerpt tag is annoying in that it adds an ellipsis (...) even if the entry body is short enough that it doesn't need to be truncated. Here's a patch that fixes this behavior.
--- MT-3.2-en_US/lib/MT/Template/ContextHandlers.pm     Tue Oct  4 17:01:01 2005
+++ mt/lib/MT/Template/ContextHandlers.pm       Sun Feb 12 00:14:12 2006
@@ -1045,7 +1045,11 @@
     $words = 40 unless defined $words && $words ne '';
     my $excerpt = _hdlr_entry_body($ctx, { words => $words, %$args });
     return '' unless $excerpt;
-    $excerpt . '...';
+    my $body = _hdlr_entry_body($ctx, { words => ($words + 1), %$args});
+    if ($excerpt ne $body) {
+       $excerpt .= '...';
+    }
+    $excerpt;
 }
 sub _hdlr_entry_keywords {
     my $e = $_[0]->stash('entry')

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.)