Over on the MT support boards sethtrain asks:
I am just starting to get the hang of making plugins. I have gotton some info from a couple of different articles on the web (the o'reilly article, how to make plugins her on MT) but I am wondering if anyone has information about the different (I really don't know what you call them) .pm files that hold information about all of MT. I really don't understand all of the
MT::Template::Contextstuff. So I was wondering if someone could explain this to me. Thanks.
(I hyperlinked the articles I assumed he was speaking about.)
I posted a reply and I thought I'd share here were it may be more easily found by others.
The .pm files are Perl Modules – code libraries that CGIs and other perl modules can use for functionality. In MT's case these modules are objects though perl modules don't necessarily have to adhere to the object-oriented programming model. (Object-oriented perl takes a bit of getting used if you've programmed in another object-oriented programming language.)
So your question is a rather big one. If you want to learn specifically about OO perl and modules, I would suggest you pickup Learning Perl Objects, References & Modules. If you are new to Perl you may want to start with its predecessor Learning Perl. The Perl Cookbook and the Perl Pocket Reference are never far from my side when I'm coding. (My selection of books has nothing to due with my association with O'Reilly.)
Most of the modules in MT have embedded documentation to its purpose, usage and methods. These docs are in POD format and can be extracted with tools like pod2html pod2text that ship with perl. You can do something like this to extract them into a file:
$ pod2text MT.pm >MT.txt $ pod2html MT.pm >MT.html
(There are other ways to do this operation – in Perl there is always more then one way to do it.) The first command (presumably executed from mt/lib) create a plain text version of the documentation in the MT.pm module. The second a HTML version. SixApart has been really good about documenting most of their modules though it has been my experience that occasionally a method or two goes undocumented in which you'll have to read through the code. The application modules are not documented because they really are meant to be extended like the others.
SixApart also posted the documentation here. Presently these pages are for MT 2.6x.
Hope that helps get you started.
<p>Over on the MT support boards sethtrain <a href="http://www.movabletype.org/support/index.php?act=ST&f=20&t=43093&st=">asks:</a></p>
<blockquote>
<p>I am just starting to get the hang of making plugins. I have gotton some info from a couple of different articles on the web (<a href="http://www.oreillynet.com/pub/a/javascript/2003/03/18/movabletype.html">the o'reilly article</a>, <a href="http://www.movabletype.org/docs/plugin-tut.html">how to make plugins</a> her on MT) but I am wondering if anyone has information about the different (I really don't know what you call them) .pm files that hold information about all of MT. I really don't understand all of the <code>MT::Template::Context</code> stuff. So I was wondering if someone could explain this to me. Thanks.</p>
</blockquote>
<p>(I hyperlinked the articles I assumed he was speaking about.)</p>
<p>I posted a reply and I thought I'd share here were it may be more easily found by others.</p>
<p>The .pm files are Perl Modules – code libraries that CGIs and other perl modules can use for functionality. In MT's case these modules are objects though perl modules don't necessarily have to adhere to the object-oriented programming model. (Object-oriented perl takes a bit of getting used if you've programmed in another object-oriented programming language.)</p>
<p>So your question is a rather big one. If you want to learn specifically about OO perl and modules, I would suggest you pickup <a href="http://www.amazon.com/exec/obidos/ASIN/0596004788/tima02-20">Learning Perl Objects, References & Modules</a>. If you are new to Perl you may want to start with its predecessor <a href="http://www.amazon.com/exec/obidos/ASIN/0596001320/tima02-20">Learning Perl</a>. <a href="http://www.amazon.com/exec/obidos/ASIN/0596003137/tima02-20">The Perl Cookbook</a> and the <a href="http://www.amazon.com/exec/obidos/ASIN/0596003749/tima02-20">Perl Pocket Reference</a> are never far from my side when I'm coding. (My selection of books has nothing to due with my association with O'Reilly.)</p>
<p>Most of the modules in MT have embedded documentation to its purpose, usage and methods. These docs are in POD format and can be extracted with tools like pod2html pod2text that ship with perl. You can do something like this to extract them into a file:</p>
<pre>
$ pod2text MT.pm >MT.txt
$ pod2html MT.pm >MT.html
</pre>
<p>(There are other ways to do this operation – in Perl there is always more then one way to do it.) The first command (presumably executed from mt/lib) create a plain text version of the documentation in the MT.pm module. The second a HTML version. SixApart has been really good about documenting most of their modules though it has been my experience that occasionally a method or two goes undocumented in which you'll have to read through the code. The application modules are not documented because they really are meant to be extended like the others.</p>
<p>SixApart also posted the documentation <a href="http://www.movabletype.org/docs/mtapi_index.html">here</a>. Presently these pages are for MT 2.6x.</p>
<p>Hope that helps get you started.</p>

Leave a comment