IncludeEx
It's frustrating that MT's Include tag doesn't process files for MT tags. So how do we fix that? Well...
This one is so short and simple, I'm just supplying it here within my weblog. If you want it, copy and paste.
# includeex.pl, to be placed in the MT 'plugins' directory.
package plugins::includeex;
use MT::Template::Context;
MT::Template::Context->add_tag('IncludeEx' => \&IncludeEx);
sub IncludeEx {
my $result = &MT::Template::Context::_hdlr_include;
if (defined $result && exists $_[1]->{file}) {
my $ctx = $_[0];
my $builder = $ctx->stash('builder');
my $tokens = $builder->compile($ctx, $result);
$result = $builder->build($ctx, $tokens, $_[2]);
return $ctx->error($builder->errstr)
unless defined $result;
}
$result;
}
1;
Hm, maybe things changed in 2.63 but there are two errors in the plugin:
1. It should say:
MT::Template::Context->add_tag
2. Though it may not be an error, the prefered package
MT::plugin::InludeEx;
jac: Correct regarding the add_tag typo. As for #2, there is no official package naming convention. In fact, the MT manual plugin examples don't name a package at all.
M'kay, I saw the differences in reverse order and was in no mood to check the second ;-)
Forgot to mention btw that it does the task perfectly. I have my links bar on every page, this include plugin enables me to make the changes only once. So tanks.
That is thanks ;-)
This works great and saved me from learning the API and coding it up myself. Thanks!