Does anyone know
- If MT4.2 support PHP Markdown and PHP Markdown Extra?
- If so, how is it to be installed?
- Once installed, does it work on static pages or only dynamic? Most of my pages are suffixed PHP, but that's only because I want to retain the option of adding simple PHP code (such as includes) when necessary. Otherwise, to all intents and purposes, they're no different from html pages and are entirely static.
Reported on Movable Type 4.2
(Answering some old questions still in the archive; sorry for the late response.)
The answer here is YES. MT, as you may know supports both static and dynamic publishing. For our dynamic publishing support, we do have PHP Markdown built-in (version 1.0.1c). You'd just need to change the publishing for your site to be dynamic instead of static to use this module.
If you want to keep static publishing and still use PHP Markdown OR PHP Markdown Extra, you can do that also. But this will require the following:
* If you're not publishing your pages as PHP files, you'll need to do that.
* Template changes so that the EntryBody and EntryMore tags are output in their raw form.
* Template changes to include PHP Markdown (or PHP Markdown Extra) module where the entry text is published.
Here, your pages would be dynamic, in the sense that they are PHP files, but they are statically published (each page view would not require access to the database for the entry content). The dynamic element would be the Markdown transformation. So instead of publishing the EntryBody tag with Markdown formatting done by MT, you'd defer that to be done when the page is viewed.
Here's a simple example showing how you would call the PHP Markdown library with the content from your entry:
<?php
include_once "markdown.php";
echo Markdown('<$MTEntryBody encode_php="q" convert_breaks="0"$>');
?>
And a similar block would be necessary to publish the EntryMore tag. Don't forget to make similar changes to the main index template and any feed you publish.
Brad,
Can you point me to the example?
Thanks.
The code didn't appear earlier; it does now, thanks to OtherNiceMan over at Pronet. Many thanks.
Actually, I think the code example is somewhat inaccurate with the later releases of MT.
If you want to use only markdown (and not markdown with smartypants) it should be:
But if you want to use smarty's smarty typography (I do), it should be:
The reason is that there is no file called markdown.php in the /mt/plugins/Markdown/php folder. The files are modifier.markdown.php and modifier.markdown_with_smartypants.php.
Also, it very likely won't work on a local Xampp installation. For that, you have to install smarty in Xampp. There's a good tutorial on that here, but while that works generally (in Xampp but outside MT), it's not enough to work with MT.
To get it to work with MT on XAMPP, you need to edit the php.ini file (c:\xampp\php\php.ini) and add this:
The first line is what is required for smarty to work outside MT. The second gets markdown-smarty working in MT on XAMPP.
PHP Markdown Extra
The shipped PHP Markdown is straight markdown ported for PHP. What's truly beautiful is Michel Fortin's PHP Markdown Extra. That is a thing of joy and beauty because it lets you
To use Php Markdown Extra, download the latest version (1.2.3 at time of writing) from here, and extract it. There's a file there called markdown.php. Rename this to modifier.markdown.php and copy it over to your Markdown PHP plugins folder (your-mt-install/plugins/Markdown/php). I suggest you rename the existing modifier.markdown.php to something like modifier.markdown.php.orginal just to be safe.
That's all. Now you're good to go, with all the advantages of PHP Markdown Extra even on your static page, even on your local installation.
Hope this helps someone. As in all things, there's probably an easier way to do this, but this one works.
Correction. The code should be
But if you want to use smarty's smarty typography (I do), it should be:
This ensures that the correct file is called relative to the root.