MovableBlog: Plugins Work in Archive File Templates
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.
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:
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