MovableBlog: Archives: August 2003
August 10th, 2003
Plugins Work in Archive File Templates »
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.
While on the subject of permalinks, I'm actually considering using the above code to change the permalink structure. Don't worry, I'll use mod_rewrite, but probably using MT to generate a rather large .htaccess, then leave it as a static file, using the MT tags found here (just above the "ErrorHandler" heading). It's the least worst way of reducing cruft while keeping all links (including links to individual comments inside entries) valid.