Archives

April 2004 (7)
March 2004 (12)
February 2004 (12)
January 2004 (22)
December 2003 (19)
November 2003 (16)
October 2003 (26)
September 2003 (18)
August 2003 (38)
July 2003 (80)
June 2003 (13)
May 2003 (24)
April 2003 (76)
March 2003 (75)
February 2003 (51)
January 2003 (73)

Category

Family (5)
FYI (18)
Games (2)
Geek (88)
Geographic (3)
Hacks (13)
Home (15)
Humor (54)
Ideas (20)
Ideaspace (15)
Local (15)
Metadata (10)
Microsoft (2)
MovableType (5)
Nitwits (66)
PKI (2)
Politics (22)
Quotes (3)
RDF (15)
RSS (4)
Security (3)
Semantic Web (13)
Site Info (13)
Social Networks (1)
Spam (9)
Sysadmin (1)
Tips (2)
Tivo (2)
TMFTOTHD (1)
To Do (1)
Unlisted (1)
Web (3)
Windows (1)

Local

« MetroBlogs »
DC metroblogs
beltway bloggers

Links


Assorted bits

Blogroll Me!
GeoURL
Listed on BlogShares




March 25, 2003

MTPingEntry plugin for MT

I'd asked the MovableType support forum for a way to make use of Entry data within comments and ping containers. This to allow running a container loop over trackbacks and comments independent of categories or entries. Ben Trott posted up a code snippet on how to do it. Here's how you can use that code in your own site.

Your MT site has the ability to use plug-ins. If you're not using them already you'll need to create a directory.

First find where your system keeps it's mt.cgi script. You'll need to create a directory here named 'plugins'. If you're connecting to your site via FTP then 'cd' to the mt.cgi directory and 'mkdir plugins'.

Now that you know the directory exists you can put plugin scripts into it. You'll need to create a text file. You'll create this locally on your computer and then use FTP to put it up on your MT site. I created a file named pingentry.pl and put this text inside it:

##
# 
# pingentry.pl
#
# code snippet from Ben Trott on the MT support board
#	http://www.movabletype.org/support/
#
# wrapped up nice and neat like this by 
#	Bill Kearney
#	http://www.ideaspace.net/users/wkearney
##

use strict;
use MT::Template::Context;
use MT::Trackback;

MT::Template::Context->add_container_tag(PingEntry => sub {
   my($ctx, $args, $cond) = @_;
   my $p = $ctx->stash('ping')
       or return $ctx->_no_ping_error('MTPingEntry');
   require MT::Trackback;
   my $tb = MT::Trackback->load($p->tb_id);
   my $entry_id = $tb->entry_id || return '';
   require MT::Entry;
   my $entry = MT::Entry->load($entry_id)
       or return '';
   local $ctx->{__stash}{entry} = $entry;
   local $ctx->{current_timestamp} = $entry->created_on;
   $ctx->stash('builder')->build($ctx, $ctx->stash('tokens'), $cond);
}); 

Save the file and then upload it via FTP to your MT site 'plugins' directory. Once that's done your MT site will automagically recognize it. Check your web server error_log just in case.

The above plugin lets you use Entry tags inside an MTPings container. I've made use of is like so:

<MTPings lastn="15" sort_order="descend">			
  <h3 class="title"><a href="<$MTPingURL$>"><$MTPingTitle$></a></h3>
  <MTPingEntry><i>Re: <a href="<$MTEntryLink$>"><$MTEntryTitle$></a></i><br/></MTPingEntry>
  <$MTPingExcerpt$>
  <div class="posted">Pinged: <$MTPingDate language="en" format="%a, %d %b %Y %H:%M:%S"$> from: <$MTPingBlogName$></div>
</MTPings>
The point of my using this container is to allow me to iterate over the pings themselves independent of entries.

Perma  | TrackBack (1) | 07:50 PM  | xml

Navigation

Recent Entries

America and Europe: Vive la différence?
Server changes afoot
Diet behavior mod
Googling for sensitive info
Outlook 2003 and IMAP, a marriage made in Hell
Bike to Work Day, May 7th
Speakeasy rocks
Zippo USB?
When geographic data is nowhere 'near' correct
Local campaign contributions

User comments
Trackbacks

Contact

send me an e-mail E-mail
chat with me using MS messenger MSN Messenger
chat with me via AIM America Online
chat with me on ICQ ICQ
chat with me on Yahoo! Yahoo
Add my vCard to your electronic addressbook vCard
Friend of a Friend FoaF

Syndication

XML  RDF  CDF

Comments

XFML

Extra Stuff

foaf
vCard
pgp info
Linked In
Powered by
Movable Type 2.64