This entry | Main blog

***Dave Does the Blog

Wednesday, 29 September 2004, 11:59 AM
MT3, dynamic publishing, and SmartyPants

SmartyPants is a text modifier that can be used to turn straight quotes to "curly quotes", dashes to em-dashes -- as they say -- dots to ellipses ... etc. I've used it for quite some time on my regular MT install, and it lends an air of polish and pretentiousness professionalism to the output.

It works just fine under MT 3.11 with static publishing. However, as expected, it doesn't work with dynamic publishing (since all the non-standard tags need to be handled as separate PHP modules). It doesn't cause an error, it just doesn't do anything.

Thereby hangs a tale ...

  1. A web search dug up a PHP version of SmartyPants. Huzzah! (Note that there is another one here, but that's not what I found first.)

  2. Download, review the instructions. No mention of MT, but there is a mention of Smarty (the PHP text rendering engine that MT uses). The instructions for SmartyPants say, If your program use the [Smarty][sm] template engine, PHP SmartyPants can now be used as a modifier for your templates. Rename "smartypants.php" to "modifier.smartypants.php" and put it in your smarty plugins folder.

  3. Try that, since there is an mt/php/extlib/smarty/plugins folder. Nada.

  4. Hmmmm. Looking in the MT dynamic publishing instructions, it mentions an mt/php/plugins directory for "Third-party MT/PHP plugins" ("Plugin files should be placed in the 'plugins' directory.").

    Of course, I have no directory by that name. Which, given my screwy install, isn't a surprise. So, create one, and try putting smartypants.php into that plugins directory.

    Nada.

  5. Okay, try putting modifier.smartypants.php into there. Nope.

  6. Google is my friend.

    Over on an 6A/MT article on PHP and dynamic publishing, I find "And with the Smarty framework, there are even more ways to customize the rendering of your page. Another feature available through Smarty is the output filter. An output filter is something that runs after the template has been executed. If, for example, you want to apply a text filtering process over your entire page (not just individual entry text), you can load an output filter to do that" and instructions on creating an an outputfilter.smartypants.php file that goes in the mt/php/plugins directory.

    So I create file as defined, and put it and smartypants.php into the mt/php/plugins directory. Then I make the mods specified in the mtview.php file, reopen the file and ...

  7. Huzzah! I have smart pants curly quotes and the like under dynamic publishing. Huzzah!

Note 1: This approach makes SmartyPants pretty ubiquitous through all the text of the (dynamic) blog pages, which means you don't have to put the smarty_pants="1" statement in the MT tags of your templates (except on static page templates), but which also means you can't easily turn it off except through the mechanisms that SmartyPants gives you.

Still, I'm pleased to have gotten that bit figured out.

Note 2: SmartyPants does its processing on the fly. Thus the static/Perl version slows down your page rebuilds as the text has to be processed at each rebuild (i.e., the text is not stored with curly-quotes in the database, just in the HTML file). The dynamic/PHP version is the same, which means that it will slow down your dynamic page displays by some (minor, server-dependent) increment.


Filed under :: Blogging

Original material on this weblog is available under a Creative Commons License (http://creativecommons.org/licenses/by-nc/1.0/) from
The views expressed by me on this website/weblog are mine alone and do not necessarily reflect the views of
my employer, my church, my party, my candidate, my community, my spouse, or, on occasion, myself.
Views expressed by others are, well, theirs.
This document's URL is: http://www.hill-kleerup.org/blog/2004/09/29/mt_311_dynamic.html