MovableBlog: Plugins Work in Archive File Templates

Nuance 2.0

August 10, 2003

If anybody's wondering how Mark Pilgrim has shorter permalinks to his posts (like the URL for this entry), the answer lies in using Movable Type's Entry Keywords field and the MTIfEntry plugin. He may do it differently: the following worked for me in an experimental installation of MT. He did tip me off to his using the Entry Keywords, however.) Plugins, as I found out recently, can be used in the Archive File Templates.

Update Aug. 14, 11:25 PM: Mark has written up an article on how he did it.

This is how I have the Archive File Templates, for the Individual Archive, setup in my experimental installation:

<MTIfEmpty var="EntryKeywords"><$MTEntryTitle dirify="1"$>.php</MTIfEmpty><MTIfNotEmpty var="EntryKeywords"><$MTEntryKeywords dirify="1"$>.php</MTIfNotEmpty>

You can get rid of cruft even further, even if you rely on PHP inside the Individual Entry archives. One could take permalinks come tantalizingly close to permalinks for the Ultimate Blogging System. The Individual Archive File Template would look something like this:

<$MTEntryDate format="%Y/%m/%d/"$><MTIfEmpty var="EntryKeywords"><$MTEntryTitle dirify="1"$></MTIfEmpty><MTIfNotEmpty var="EntryKeywords"><$MTEntryKeywords dirify="1"$></MTIfNotEmpty>

To parse as PHP (my host automatically parses .php files, but it's not automatic for other files), one could put the following line in .htaccess, and your archives folder would be a good candidate for the file's location:

ForceType application/x-httpd-php

So the link to this entry, instead of being fairly crufty (and lacking the year in it), would, if I had typed the word "Permalinks" in the Keywords field (without quotes), look something like http://www.movableblog.com/archives/2003/08/10/permalinks. But if there's no words in the Entry Keywords field, the Entry Title is used to create the filename. Of course, that depends on actually putting in something for the Title, but that's never a problem for me.

But the moral of this story is that plugins work inside the Archive File Templates, which means a lot of fun can be had with constructing MT blog's URLs.

read the rest of this article

Posted by Richard at 7:08

Comments

Thanks for the tips.. I didn't know you could use plugins in the archive file templates, either. I can see a lot of fun happening there. :)

I think I'll change my system soon too. I don't like all those .php's.

Great tips! Too bad I'd end up butchering all my existing permalinks to pull off better URLs. Maybe I'll have to re-implement that 404 hack I got on scripty goddess.

Ah, but that's the thing: if your host has it, you can use mod_rewrite to move over to new URLs easily. And it has the advantage of any anchors (you know, URLs that look like http://www.example.com/archives/2003_08.php#001111) redirect without losing the anchor. If you look at the code pointed out above (here, scrolling down to just above "ErrorHandler"), you can even do it in MT!

God I love Apache. Thanks, Richard!

Richard,

Thanks for the post albeit I hadn't the ghost of an idea of what you talked about.

At long last, He spoke up.

http://diveintomark.org/archives/2003/08/15/slugs