February 27, 2005

MT QuickPost hack

Since I started blogging with Movable Type, I've been using a feature formerly called Bookmarklet, now called QuickPost, for posting articles referencing other web pages. One thing that's driven me nuts is that I always had to go in and add the text 'target="_blank"' inside the link URL, so that folks clicking it would get a new window with that link instead of automatically being taken away from my pages and having the link open in that same window. Anyway, I finally dug into the code that the QuickPost code uses and found a fix.

The relevant file is (for my installation) /CGI-Executables/lib/MT/App/CMS.pm, your actual path may vary.

if ($q->param('is_bm')) {
    $param{selected_text} = $param{text};
    $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
        scalar $q->param('link_title'),
        scalar $q->param('link_href'),
        scalar $q->param('link_title'),
        $param{text};

The 3rd line there is the key, the one that actually puts the link into the web page. Simply change it to read as follows, and save the file:

        $param{text} = sprintf qq(<a title="%s" href="%s" target="_blank">%s</a>\n\n%s),

Now, open your Bookmarklet/QuickPost, and the revised link should now be used. Of course, you will need to revise this code each time you upgrade, so you may want to make a note somewhere to yourself about this. ;)

Posted by Jim at February 27, 2005 9:18 PM | TrackBack