How to combine MT::Plugin subclasses with config.yaml files

| 0 Comments
When I was working on refactoring part of the FacebookCommenters plugin to use a config.yaml file, I had to account for the save_config method that the plugin's pl file implemented. Movable Type plugins that are based on PL (Perl) files subclass MT::Plugin and accordingly can override methods in MT::Plugin like save_config. Getting around that is actually really this simple:

The perl module which implements the subclass:

package FacebookCommenters::Plugin;
use strict;
use base qw(MT::Plugin);

sub save_config
{
    my $plugin = shift;
   
    #Do stuff
   
    return $plugin->SUPER::save_config(@_);
}

1;
add this code (use 4 spaces, not tabs for indentation) to the config.yaml file:

init: >
    sub {
        my $plugin = shift;
        require FacebookCommenters::Plugin;
        bless $plugin, 'FacebookCommenters::Plugin';
    }
That's based on a trick that was explained on the Movable Type mailing list, but needed to be shared.

Leave a comment

March 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Recent Entries

A window into the totalitarian mind of the left on freedom of religion
From Digg: Me: I'm not going to hold my breath waiting for the same liberal democrats who shriek about the…
Google's lossy compiler
Google's closure compiler service gets a little too frisky under ADVANCED_OPTIMIZATIONS. Original code: With advanced optimizations enabled, it was able…
The three purposes of the federal income tax law
Businesses will spend about 3.4 billion man-hours and individuals about 1.7 billion hours figuring out their taxes this year.…

Subscribe

Advertisements

OpenID accepted here Learn more about OpenID