dynamically-generated individual archive pages
MT 2.6 and greater comes with an "experimental" CGI program called mt-view.cgi. In order to use this you will have to turn off safe mode in your configuration file mt.cfg.
Stepan Riha came up with a hack to mt-view.cgi that allows users to create custom dynamic pages.
If you use PHP code in your templates, the CGI will not parse it. The PHP code will appear right there on the page. So you have to include the CGI in a PHP page in order to parse the PHP code. This requires you to have two templates for each individual entry archive, the one that the CGI uses and the PHP include. That's what Stepan's hack allows.
If you want to do this, configure your MT install to use mt-view.cgi and apply Stepan's hack. Then go into MT and create a new archive template. I've called mine "Dynamic Individual Entry Archive". This template will be for the PHP include and contains the following code:
<?
include('<$MTCGIPath$>mt-view.cgi/<$MTBlogID$>/entry/<$MTEntryID$>/iea');
?>
I had renamed my main template (the one with the content) as "iea" and that is the "iea" referred to here.
Next, go into Weblog Config and select Archiving. Click the "Add New..." button and add a new individual archive. Select the new dynamic template that you created (the one with the PHP code; mine is called Dynamic Individual Entry Archive). If you have a customized path to your individual entry archive pages using the Archive File Template, copy this path into the Archive File Template for your new dynamic template. Now delete the old individual template (the main one; mine is the "iea" template) from this list. Finally, rebuild your blog.
Let me explain what you've done by these steps. You want people to load the PHP page in their browsers so you need to have that be your official individual template (so the permalinks will point to it). You do not need MT to create a set of pages using the full template (the one I've called "iea"). In fact, to save server space you don't want MT to do this. That's why you remove it from your Archiving configuration.
When the browser loads the PHP page, the server reads the PHP code and sees that it needs to include the results of mt-view.cgi, specifically the results of mt-view.cgi for the appropriate blog entry, using the template file "iea". The server includes this page and also parses any PHP code then presents the results to the visitor.
So there you are: a dynamically-generated individual archive page with PHP. Your permalinks stay the same; in fact it's invisible to the user that the page is dynamically generated.
There is a very important caveat before you do this. It is very database intensive. Think about your hosting plan's limits on database usage and whether you can afford an upgrade if necessary. I've discussed some of these issues in a thread at the MT support forums.
If your hosting plan can handle the database usage, you may like having dynamic individual entry archive pages. I do. I never have to rebuild them when I make template changes because they're created directly from the database when a browser loads them. This is also a great benefit when displaying comments and trackbacks on the individual entry archive page. As to comments, frequently the server may time out when processing a new comment and the individual entry archive page doesn't get rebuilt. This means that people may submit their comment repeatedly, which you have to delete, and you have to keep track of which entries you need to rebuild. As to trackbacks, MT doesn't rebuild individual entry archive pages at all for them, because of the time-out problem. Having a dynamically-generated individual entry archive page resolves both of these problems.
If you think that the benefits outweigh the drawbacks, I encourage you to use this method.
Update: Although I had been using this without problems for nearly two years, my webhost recently informed me that mt-view.cgi was using up too many server resources, so I have switched back to static individual archives for the indefinite future.
Subscribe to this blog's feed