Movable Type hacks

This has been on my list for a while, and now that it’s implemented it’s certain to be something I’ll use daily. Note: this requires PHP to implement.

What I’ve done is pretty straightforward: to visitors, nothing has changed. But for me, whenver I visit my weblog, I see an “edit” link next to every post and every comment. If I click on those links, a new window opens up — directly to the edit window in Movable Type for that post or comment. This is a great time saver — whether it’s for a spam comment I see that I’d like to easily delete or a typo I catch in my post that I’d like to clean up.

The original idea for this comes via The Girlie Matters, though I did things a tad differently.

Here’s the details:

From the “Templates” page, create a new index template. Call it “Set cookie” (or whatever you want); name the file cookie.php (or something else — but make sure the file extension is .php.) In the body of the module, enter:


Be sure to set “yourdomain.com” to your domain. “www” is not necessary.

Uncheck the box that says “rebuild this template automatically”, click save, then click “rebuild”.

Create a second template, called “remove cookie” with an appropriate filename (again, be sure that the file extension is .php.) In the body of the modle, enter:


Uncheck the box that says “rebuild this template automatically”, click save, then click “rebuild”.

Now go to your main index template. Figure out where you want to add the “edit” link for your posts, and insert the following code:

mt.cgi?__mode=view&_type=entry&id=
&blog_id=" target="_new">[edit]';
if ($HTTP_COOKIE_VARS['edit'] == 'password') {
echo $edit_link;
}
?>

(Note that I put a break in between &id= and MTEntryID; I did that for spacing but you should put it all on one line.)

Save the main template. Go to your individual index template and add the following code where you want the “edit” link to show up for comments:

mt.cgi?__mode=view&_type=entry&id=
&blog_id=" target="_new">[edit]';
if ($HTTP_COOKIE_VARS['edit'] == 'password') {
echo $edit_link;
}
?>

(Note the spacing; delete the line break between &id= and MTEntryID.)

Save the template. Rebuild your site. Now go to yoursite.com/blog/cookie.php (or whatever you called that file); the page will be blank but the cookie will be set. Now visit your homepage; next to each post there should be an “edit” link. Visit any of the individual pages and you will see an “edit” link next to each comment.

The nice thing about this is that the “edit” link doesn’t show up unless you’ve set the cookie (one way to secure the cookie getting set is to publish it to a password-protected directory), and even if someone were to guess the file to set the cookie on their machine, they’d still need to login to Movable Type to get access to the edit boxes.

This would be a great solution for heavily commented sites where some number of the comments are inflammatory or otherwise inappropriate; with two clicks, you could delete the comment directly from the page on which they’re published. I just like having the edit button available at all times — it makes administration a much simpler task.

5 responses to “Movable Type hacks”

  1. MT Direct Edit Hack (& Total Choice Hosting)Rick Klau has some nifty Movable Type hacks, including adding the ability to have easy to use “edit” buttons visible only to the blog owner. Rick also has some kind comments on Total Choice Hosting. My comments on various other…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.