How to combine MT::Plugin subclasses with config.yaml files
December 22, 2009
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:
The perl module which implements the subclass:
package FacebookCommenters::Plugin;add this code (use 4 spaces, not tabs for indentation) to the config.yaml file:
use strict;
use base qw(MT::Plugin);
sub save_config
{
my $plugin = shift;
#Do stuff
return $plugin->SUPER::save_config(@_);
}
1;
init: >That's based on a trick that was explained on the Movable Type mailing list, but needed to be shared.
sub {
my $plugin = shift;
require FacebookCommenters::Plugin;
bless $plugin, 'FacebookCommenters::Plugin';
}
