MT: Easy comment and entry editing

This entry was published at least two years ago (originally posted on January 20, 2003). Since that time the information may have become outdated or my beliefs may have changed (in general, assume a more open and liberal current viewpoint). A fuller disclaimer is available.

Responding to Dave Winer expounding upon the virtues of Manilla (the CMS Dave creates), Morbus offers this tip for MovableType users:

The “Edit This Page” button may not be a default item in the Movable Type templates, but it is certainly possible — I’ve been using it on the individual archives of Gamegrene.com for quite a long time (it’s there, but is an invisible pixel gif at the bottom of the page). Add the following to your templates and, assuming you’re cookied into the MT adminterface, you’ve got your “Edit This Page” equivalent (broken across multiple lines for ease of reading):

<a href="/cgi-bin/mt/mt.cgi?__mode=view&_type=entry& blog_id=1&id=<MTEntryID>">Edit This Page with Movable Type</a>`

I use a similar technique here, only one that allows me to not have to worry about the blog ID number, and I have ‘edit’ links both for each individual entry, and for any comments that are left on my site. As a bonus, the edit links are hidden, so unless you’re me (or you read this post), you’ll never know that they’re there!

I use a combination of HTML, JavaScript, CSS, and MT tags in the “Posted by…” link on every post and comment to allow me to jump directly into editing mode if I need (either due to a typo or revision on my part, or to clean up or delete any unneccessary comments left by visitors), yet keep it hidden from casual prying eyes.

First off, the code for the “edit post” links as it resides in my MT templates (all one line in the template, broken here for readability):

Post<a href="<MTCGIPath>mt.cgi?__mode=view&amp;_type=entry&amp; id=<MTEntryID>&amp;blog_id=<MTBlogID>" target="_blank" onmouseover=“window.status=’’; return true;” class=“hidelink”>ed</a> by <MTEntryAuthor>`

By using the <MTBlogID> MT tag rather than just typing in “blog_id=X“, we avoid any problems with having the wrong blog ID chosen if you’ve moved the code from one template to another, or don’t know the ID number of the blog you’re working with.

The onmouseover="window.status=’‘; return true;" bit of JavaScript ensures that the status bar of the browser does not change when someone mouses over the link — one of the visual clues to the existence of a hyperlink. Note that there are actually two single quotation marks with nothing between them after the window.status= declaration — if you type them as double-quotes, you’ll break the code by closing out the onmouseover function too early. The’return true;‘ declaration is just there to ensure that the link will get passed to the browser correctly when clicked on.

The last special bit to the tag is the class=“hidelink” declaration. This is calling on a class I have set up in my CSS stylesheet that looks like this:

a.hidelink:link, a.hidelink:visited, a.hidelink:hover, a.hidelink:active {
    text-decoration: none;
    color: #7f7f4d;
    cursor: text;
    }

This set of CSS rules ensures that any HTML anchor with the class ‘hidelink’ will have no text decoration (under- or over-lining or anything else), will be the same color as the surrounding text, and the cursor will not change to the standard ‘pointy’ cursor as it moves over the link. Between this CSS and the JavaScript code in the link, the end result is a working, active link that is entirely hidden from most browsers (and even if someone does find the link, they’ll still need to know your MT login and password to be able to make any changes).

The same trick can be used on comments, to jump you directly to the comment editing screen. Here’s the code I used in the “Posted by…” line for comments on this site (again, as one line in the template):

On <a name=“<$MTCommentID pad="1"&gt;"&gt;&lt;$MTCommentDate$&gt;&lt;/a&gt;, &lt;$MTCommentAuthorLink spam_protect=”1“$&gt; post&lt;a href="&lt;$MTCGIPath$&gt;mt.cgi?__mode=view&amp;amp;_type=comment&amp;amp; id=&lt;$MTCommentID$&gt;&amp;amp;blog_id=&lt;$MTBlogID$>” target="_blank" onmouseover=“window.status=’’; return true;” class=“hidelink”>ed</a>:`