February 27, 2003
The built-in <MTElse> tag only works with built-in conditional tags such as MTEntryIfExtended. It does not work with plugin conditional tags, such as MTEntryIfComments. This hack modifies MovableType to support MTElse in any conditional plugin tag.
lib/MT/Builder.pm Modification
Go to your MovableType installation directory, and open the file Builder.pm in the lib/MT subdirectory.
- Find the line (line 98 in MT 2.63) that says:
my($tokens, $uncompiled);
and add the following line after it:
my $tokens_else;
- Find the line that says:
$tokens = [ grep $_->[0] ne 'Else', @{ $t->[2] } ];
and add the following line after it:
$tokens_else = [ grep $_->[0] eq 'Else', @{ $t->[2] } ];
- Find the line that says:
$ctx->stash('tokens', $tokens);
and add the following line after it:
$ctx->stash('tokens_else', $tokens_else);
lib/MT/Template/Context.pm modification
Go to your MovableType installation directory, and open the file Context.pm in the lib/MT/Template subdirectory.
- Find the section (line 43 in MT 2.63) that says:
if ($condition->(@_)) {
return _hdlr_pass_tokens(@_);
} else {
return '';
}
and replace it with the following section:
if ($condition->(@_)) {
return _hdlr_pass_tokens(@_);
} else {
my($ctx, $args, $cond) = @_;
return $ctx->stash('builder')->build($ctx, $ctx->stash('tokens_else'), $cond);
}