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;

TrackBack

TrackBack URL for this entry:
http://bradchoate.com/mt/feedback/tb/547

Listed below are links to weblogs that reference IncludeEx:

» IncludeEx from lovelinks
Brad Choate: IncludeEx -- little plugin to make MT parse files linked to modules. [Read More]

» MT Plugins Installed from Technology Updates
The following MovableType plugins were installed: From Brad Choate IncludeEx - Improves on MT’s Include tag by processing the included file for MT tags. MTAuthors - This plugin allows you to list the authors for your blog. You can also... [Read More]

5 Comments

jac said:

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;

Brad Author Profile Page said:

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.

jac said:

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.

jac said:

That is thanks ;-)

Omer Shenker said:

This works great and saved me from learning the API and coding it up myself. Thanks!

About

This article was published on January 27, 2003 12:17 PM.

The article previously posted was Supplemental Calendar Tags.

The next article is Better Google Groups searches.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type