Posts Tagged ‘mt4’

Movable Type: Update Entry Date

Thursday, January 24th, 2008 at 8:05 pm

My favorite plugin in MT3 was UpdateAuthoredOn. It didn’t do much: you got a button next to the entry date input, and clicking on it would update it to the current time and date. Simple, but very handy - especially if you’re the kind of person who writes an entry over the course of a couple days and want to post it with the current time.

The new version is called UpdateEntryDate, but it’s not working for me in MT4. So, I ripped out the part I needed and changed the MT template. If you want to try it out, you’ll need to modify tmpl/cms/edit_entry.tmpl in your MT directory. Go to line 1057 (give or take), or search for entry-time to find the date and time inputs.

First, the time input needs an ID. You can replace the whole entry-time input with this:

<input id="entry-time" class="entry-time" name="authored_on_time" tabindex="11" value="<$mt:var name="authored_on_time" escape="html"$>" />

Then insert this two lines down, after the closing span tag:

<input type="button" class="primary-button"
onclick="update_authored_on();" value="Update" />
<script type="text/javascript">
function zeropad(num) {
return (num < 10) ? '0' + num : num;
}
function update_authored_on() {
var now = new Date();
var y = now.getFullYear();
var m = zeropad(now.getMonth() + 1);
var d = zeropad(now.getDate());
var h = zeropad(now.getHours());
var min = zeropad(now.getMinutes());
var s = zeropad(now.getSeconds());
document.getElementById("created-on").value = y + '-' + m + '-' + d;
document.getElementById("entry-time").value = h + ':' + min + ':' + s;
}
</script>

Movable Type: Archives Location Change With Upgrade

Wednesday, January 23rd, 2008 at 10:19 pm

As I’ve mentioned here before, I upgraded to Movable Type 4 not too long ago. One of the changes that almost went unnoticed is the way archives are handled. In MT3, I wasn’t using the dynamic pages, so every post was generated into a file in the archives directory. For example, a post about new music in July wound up at /archives/2007/07/new_music.php.

In MT4 - or at least, MT4 with dynamic pages - there is no archives directory. Really, there aren’t any directories, since it’s all handled by mod_rewrite, but that’s not really the point I’m making. Under MT4, that post I mentioned above would be at /2007/07/new_music.php, with no /archives at the front.

Now, I could change the Archive Mapping on the Entry Archive Template in the admin, but I kind of like the shorter URLs. I don’t know much about mod_rewrite, but I found an answer a lot quicker than I expected to, thanks to askApache. I just added this to the .htaccess file in my site root, and now any requests to the non-existent archives directory are re-directed back into the root.

RedirectMatch ^/archives/(.*)$ http://www.brockli.com/$1

If you want to use this for your site, you’ll need to replace brockli.com with your own URL, but that should be it.