In my last tutorial, I explained how to use the MT-Collect plugin to create a print-friendly entry template. One problem with this method is, since MT-Collect is an older plugin, it doesn’t work with dynamically published templates. This is a shame, since a print version really lends itself to dynamic publishing.
So, I set out to find a way to make this template dynamic. The solution was to write my own plugin that has the same results as we get with MT-Collect. And in this tutorial, I’ll show you how to use it.
First, a little background. In Movable Type, static and dynamic publishing are very different beasts. Static templates are processed by MT’s Perl engine. The core of this template engine is the Perl module HTML::Template. Dynamic publishing is processed by PHP and is based on Smarty. Since the two systems are based on different languages, plugins have to be written twice: a Perl version for static publishing, and a PHP version for dynamic. That’s why older plugins, like MT-Collect, don’t work with dynamic publishing. They were written before MT’s dynamic publishing engine was introduced, so they don’t include a PHP version.
What I’ve done, at this point, is create a plugin that’s strictly for dynamic publishing. Since we already have a way to statically publish our print-friendly templates, I concentrated on the PHP side of things. So if you’re happy with static publishing, use the method I described last time. If you want your print version published dynamically, read on.
Download this plugin and install it in your Movable Type blog. This is alpha-level code, but it only affects the output of your data, so you shouldn’t need to worry about it damaging your system. After it’s installed, download this file, which contains the archive template and the print CSS file. Install those according to the instructions in the previous tutorial. The only difference will be when you create the archive mapping. For the archive mapping, set Publishing to Dynamically.
Now, let’s take a quick look at what’s different in this template:
We’ve dropped all the MT-Collect tags and just wrap the content we want to pull links from in the
<mt:countlinks> will add the link index (e.g. “”) next to each link. It also stores the content it processed for use by this next tag:
URL to article: <$mt:EntryPermalink$>
<mt:postlinks /> tag outputs our list of URLs, with the appropriate index numbers.
You should now be able to visit one of your “print article” links (that we set up in the last tutorial) and get the print version served dynamically. If it doesn’t work and this is your first time publishing dynamically, review the documentation to make sure it’s set up correctly. If you’ve successfully published dynamically before, leave a comment — you may have found a bug.
Hopefully, those of you that were wanting a dynamic solution will find this useful. I will continue to work on this plugin to add more features and to make it work statically as well. Tune in to Movable Type Mondays to find out how it’s progressing.