22. AddingâŠaâŠConďŹgâŠDirecEve
name: Good for Nothing Plugin for Movable Type
id: Good4Nothing
key: Good4Nothing
author_link: http://www.yourwebsite.com/
author_name: Your Name Here
description: This plugin is an example plugin.
version: 1.0
config_settings:
MyImageURL:
default: http://path.com/images/foo.jpg
PageâŠ
26. AddingâŠaâŠTemplateâŠTagâŠââŠconďŹg.yaml
name: Good for Nothing Plugin for Movable Type
id: Good4Nothing
key: Good4Nothing
author_link: http://www.yourwebsite.com/
author_name: Your Name Here
description: This plugin is an example plugin.
version: 1.0
config_settings:
MyImageURL:
default: http://path.com/images/foo.jpg
tags:
function:
MyImageURL: $Good4Nothing::Good4Nothing::Plugin::tag
PageâŠ
27. AddingâŠaâŠTemplateâŠTagâŠââŠHandler
# Good for Nothing Plugin for Movable Type
# Author: Your Name Here, your.email@address.com
# Copyright (C) 2008 Your Name Here
# This file is licensed under the Artistic License,
# or the same terms as Perl itself.
package Good4Nothing::Plugin;
use strict;
sub tag {
my ($ctx) = @_;
my $cfg = $ctx->{config};
return $cfg->MyImageURL;
}
1; # Every module must return true
PageâŠ
30. MoreâŠaboutâŠTemplateâŠTags
# Example: <mt:SaySomething>
sub SaySomething {
my ($ctx, $args) = @_;
return quot;Somethingquot;quot;;
}
# Example: <mt:SayWhatever say=âHelloâ>
sub SayWhatever {
my ($ctx, $args) = @_;
# What the person passed in through the
# argument 'say'
my $input = $args->{'say'};
return $input;
}
PageâŠ
31. MoreâŠaboutâŠTemplateâŠTags
# Example: <mt:LoopTenTimes>...</mt:LoopTenTimes>
sub LoopTenTimes {
my ($ctx, $args, $cond) = @_;
my $out = quot;quot;;
my $builder = $ctx->stash('builder');
my $tokens = $ctx->stash('tokens');
for (my $i = 1; $i <= 10; $i++) {
$ctx->stash(quot;current_loop_numberquot;,$i);
$out .= quot;$i * quot; . $builder->build($ctx,$tokens,$cond);
}
return $out;
}
# Example: <mt:IfOdd>do this</mt:IfOdd>
sub IfOdd {
my ($ctx, $args, $cond) = @_;
my $num = $ctx->stash('current_loop_number');
if ($num % 2 == 0) {
return 0;
} else {
return 1;
}
}
PageâŠ
33. AddingâŠaâŠTemplateâŠTagâŠââŠconďŹg.yaml
name: Good for Nothing Plugin for Movable Type
id: Good4Nothing
key: Good4Nothing
author_link: http://www.yourwebsite.com/
author_name: Your Name Here
description: This plugin is an example plugin.
version: 1.0
config_settings:
MyImageURL:
default: http://path.com/images/foo.jpg
tags:
modifier:
lolcats: $Good4Nothing::Good4Nothing::Plugin::lolcats
PageâŠ
34. AddingâŠaâŠModiďŹerâŠââŠHandler
# Good for Nothing Plugin for Movable Type
# Author: Your Name Here, your.email@address.com
# Copyright (C) 2008 Your Name Here
# This file is licensed under the Artistic License,
# or the same terms as Perl itself.
package Good4Nothing::Plugin;
use strict;
sub lolcats {
my ($str, $val, $ctx) = @_;
return quot;CAN I HAZ â. uc($str);
}
1; # Every module must return true
PageâŠ
47. ExtendingâŠExisEngâŠObjects
name: Example Plugin for Movable Type
id: Example
key: Example
description: This plugin is an example plugin
version: 1.0
schema_version: 2
object_types:
entry:
is_featured: smallint
PageâŠ
52. AddingâŠaâŠCallbackâŠââŠconďŹg.yaml
name: Good for Nothing Plugin for Movable Type
id: Good4Nothing
key: Good4Nothing
author_link: http://www.yourwebsite.com/
author_name: Your Name Here
description: This plugin is an example plugin.
version: 1.0
callbacks:
MT::Entry::pre_save: $Example::Example::Plugin::pre_save
PageâŠ