Fixing <MTEntryModifiedDate> in dynamic templates

According to the Movable Type support desk it’s a known bug that <MTEntryModifiedDate> sometimes returns the original publishing date rather than the modification date when used in a dynamic template. I think this must be a regression of the same bug from 2.661 mentioned here, but now it only affects dynamic publishing.

Luckily, the fix is much easier to implement this time. Simply backup /path/to/mt/php/lib/function.MTEntryModifiedDate.php and then edit it so the file looks like this (or download the whole file):

<?php
function smarty_function_MTEntryModifiedDate($args, &$ctx) {
    $e = $ctx->stash('entry');
    $args['ts'] = $e['entry_modified_on'];
    return $ctx->_hdlr_date($args, $ctx);
}
?>

I should probably understand this sort of stuff better (you did backup your current file, right?) before I go hacking around, but I figured that my <MTEntryDate> tags were working correctly in my dynamic templates. Why not just copy the code out of that PHP file (function.MTEntryDate.php), change ‘entry_created_on’ to ‘entry_modified_on’ and see what happens?

Whadaya know, it worked! (With no ill effects, knock on wood.) Now my dynamic Atom feeds have the correct date in the updated field.

Popularity: 6% [?]

Leave a Reply