« テンプレートマッピング | Home | MTCalc0.1 »

February 18, 2006

MTHello?

プラグインを作ったりしたい。 という事で試みに作ってみたプラグインである。九割がぱくりである。一応動く。 ちなみに perl の知識は殆ど無いので、必要の無いコードが混じっていたりするかもしれません。 仕様 : hello? 仕様2 : アトリビュート "Name" で指定した名前に hello?
以下、そのコード。コメントはかっこつけマンなので英語にした。多分どこか変。
#Hello? Plugin of Movable Type 3.2
#aklaswad 2006 feb 5th
#this plugin just add a MTtag that print "hello?" 

package MT::Plugin::Hello;   #Declare the Module space (Namespace?) in Perl
use strict;                  #this line force to the code to be Gentle to Declare 
use base 'MT::Plugin';       #Load MT Module?
use vars qw($VERSION);       #Version
$VERSION = '1.0';

use MT;                      #Load MT Module?
use MT::Template::Context;   #Load MT Module?

#Constractor of my plugin class
my $plugin = MT::Plugin::Hello->new({
    name => 'Hello? Movable Type',
    description => "say Hello?",
    doc_link => 'http://www.sixapart.jp',
    author_name => 'aklaswad',
    author_link => 'http://www.aklaswad.com/',
    version => $VERSION,
});

MT->add_plugin($plugin);     #pass my plugin class to MT

#Add an External tag's name and that's routine's address
MT::Template::Context->add_tag(Hello => \&tag_hello);   

#My new External MTtag's code
#return balue will output to the document
sub tag_hello {
  # get arguments 
  my ($ctx, $args) = @_;
  my $name = $$args{"name"};
  "hello? $name";            #return value
}

1;

No TrackBacks

TrackBack URL: http://aklaswad.com/cgi-bin/mt/mt-tb.cgi/3

Leave a comment

OpenID accepted here Learn more about OpenID

About this Entry

This page contains a single entry by aklaswad published on February 18, 2006 1:46 AM.

テンプレートマッピング was the previous entry in this blog.

MTCalc0.1 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.