Photo Plugin
I wanted to be able to embed tags into an entry, perhaps in a hierarchical sequence. The tags would contain the photo path, and some text description. These tags would be parsed into a proper HTML table, that would be pleasing to view. I imagined an XML format, perhaps with a container entity so that one's photo entry could have a pure text prelude and a conclusion.
My first attempt at this is located here. This may be useable, if only barely. There were some good lessons learned, though:
- Normal MT tags cannot be used within entries. I probably should have know this. It is somewhat unfortunate, as MT has a great tag scheme for its templates. The only way to be able to do processing of entries is via a text-formatting plugin.
- It is difficult to include XML tags in a text-formatting plugin, for at least two reasons. First, the MT editor automatically changes strange < and > signs into the appropriate thing for HTML. That means that they are not passed into the text filter. Second, even if they were passed in, I probably would not be able to use an XML parser, as there may be text before and after the XML tree. (Maybe that can be handled with some parsers, but I don't know how.)
- Plugin installation is surprisingly easy. But, I was originally frustrated when I could not get normal MT tags to work in my entry. I was then frustrated when I misspelled "Plugins" as "Plugin". I guess that I am easily frustrated. Still, most of my computing career has been on the Windows platform, so installing a module by dropping it into the right directory makes me almost giddy with joy.
- Because I could not include XML-like tags into the entry, I had to parse for bare text. I tried to make the syntax obvious by capitalization and end-tags (like XML without the brackets). It seemed easiest to write the parsing code in a "stateless" way, but I recognize that is not a very maintainable way of doing it. Wow, do I want to use a real XML parser.
- There seems to be some good documentation out there. Timothy Appnel's writeup was an excellent introduction. The original discussion of the text-formatting plug-in feature is described here. The MT manual contains some information about plugins. The best place, of course, is the Plug-Ins Directory. It is almost a necessity to look at some working examples.
Well, I will continue to think about the issues in doing what I am trying to do. Perhaps there is a reasonable solution. I am far from a Perl guru, and maybe some wise master has already uploaded what I need to CPAN.
I continue to be impressed with Moveable Type and the community that has grown up around it. Perhaps if I can work out my issues, this little plug-in will be useful to others, too.
Example of what I am trying to do:
Here is some text. | |
Here is some text. |