The Movable Type User Manual

NOTE: This documentation is for Movable Type 3.2. If you are using a newer version, please see the documentation for Movable type 3.3x or Movable Type Enterprise.

« 10: Search | Up | 12: Getting Help »

Chapter 11: Advanced Topics

In this section:


With broad platform integration of all the leading open standards, Movable Type has the potential to do much more, given additional expertise and knowledge on the user's part.

This chapters covers some of the more advanced features in addition to providing a starting point for more advanced topics not covered in this publication.

Architectural Overview

Movable Type is written in a highly modular Perl object-oriented style with an open code base (it's not open source -- an important distinction) that makes the browser-based tool quite flexible and easily modifiable, allowing it to adapt to any number of publishing applications. Since the release of version 2.2 in June 2002, extending MT has become easier and more elegant with the introduction of a plug-in framework that continues to be enhanced with each new release. With the release of version 3.0D, Movable Type made the official leap from a personal publishing system to a platform.

The use of the Perl programming language to develop Movable Type provided a highly flexible environment for manipulating text and data structures. Perl was (and still is) widely adopted with vast amounts of pre-existing knowledge and experience throughout the on-line world. The Comprehensive Perl Archive Network (CPAN) and its collection of libraries provided MT and its developers with a trove of functionality to get started with. Perl also provided the ability to run on virtually any operating system and environment -- particularly on low-cost, shared hosting packages that were essential to MT's early growth.

In the tradition of the programming language that it is almost entirely written in, Movable Type is a "glue" system. It makes extensive use of open standards and open source technology, gluing them together into a cohesive system. While the MT code base has grown to a size that the typical Perl program is not known for, its code base is tiny in comparison to many commercial and much more expensive web applications, thanks in part to the wide range of Internet infrastructure and tools it utilizes.

Movable Type adopted a static publishing model where content and meta-data along with templates were stored in the application's database and merged into static files. This sets Movable Type apart from most weblog tools that generate their pages exclusively in dynamic fashion. To some this model has been a long-standing criticism of MT that was recently addressed in part with the release of version 3.1 that introduced the option of PHP-based, dynamic page generation.

The decision to architect MT in an object-oriented fashion was significant in its early growth and its strengths today. Adopting OO principles allowed MT to adapt and innovate to the burgeoning personal publishing explosion and ultimately provided the first important steps towards its status as a platform.

Problem

You want to monitor the activity of a Movable Type system or weblog.

Solution

Use the Activity Log to view and filter all common actions that have taken place on the system.

Discussion

The Activity Log records all common actions that take place in a Movable Type installation. This log provides administrators and weblog publishers with important information to how the system is running. This information includes:

  • Successful logins and incorrect login attempts
  • Creates, updates, and deletes of weblogs and entries
  • Deletes of comments and TrackBack pings
  • Detailed errors generated by plugins
  • MT search engine queries

Click the Activity Log button on the System Toolbar or the Weblog Toolbar. Entering the log from the Weblog Toolbar will automatically filter the activity for a specific weblog.

In addition to the Activity Log interface, this data can also be searched using the built-in search and replace tool. (See "Using Advanced Search and Replace Functions".) Two of the many ways that you can filter using the search tool include specific string or date range.

Exporting the Activity Log in Comma-Separated Value (CSV) Format

Movable Type now makes it easy to get your Activity Log data out of the system using the universally supported CSV export format. Using this feature, log data can be backed up or further analyzed and graphed in a spreadsheet application. The potential uses are many.

To get a CSV export of the data, go into the Activity Log and click the "Export in CSV" link at the top of the screen. The file will begin downloading in your browser. If you are viewing activity for a specific weblog, the exported file will also be limited to that specific weblog.

Problem

You need to find or replace data, and the quick search box is not sufficient.

Solution

Use the Search & Replace tool to find and optionally replace text found in the content.

Discussion

The quick search box found on nearly every screen of the Movable Type interface is great for quickly looking up information, but could fall short if you need something more granular. In these cases you can use the Advanced Search and Replace tool to find text and optionally replace, it in a wide variety of items in the application. These items include:

  • Entries
  • Comments
  • Commenters
  • TrackBack Pings
  • Activity Log
  • Templates

To use the tool, click the Search button on the Weblogs Toolbar. The functionality is also available as a system level resource by clicking the Search button on the System Toolbar.

Across the top are tabs for the application items you can search. Under the search box will be a number of different options to more precisely tailor your search. Which options are available will vary slightly based on what items are searched. These options are:

  • Case Sensitive

    By default, searches are case insensitive. Checking this option the case of the search term will be considered.

  • Regular Expression (RegEx) Match

    With this option enabled, the term will treated as a regular expression pattern. A regular expression is a string that describes or matches a set of strings according to certain syntax rules. For more on regular expressions see http://en.wikipedia.org/wiki/Regular_expressions.

  • Limited Fields

    Selecting this option will open a dynamic control to define which fields to perform the search on.

  • Date Range

    This option limits the search to a specific date range. Selecting it will open a dynamic control where you can enter a start and end date.

    The date controls are rather vague. What format are dates to be entered?

  • Is Junk

    Available only on comments and TrackBack ping searches, this option limits the search to items marked as junk.

Once you have entered a query and selected the applicable search options, click the Search button to run it. The results will be returned in the same listings interface found throughout the application, including all of the controls for managing and acting on the found items.

Having performed an initial search, you can search again, or perform a search and replace on all or some of the results.

Search & Replace

With the results of a previous search displayed, Movable Type gives you the option of finding the term and replacing it with another string. This operation does not have to be performed on all the results. You can choose to replace matches in just a few selected search results or constrain the operation to specific fields of those items. For instance, you could search templates for a specific file path and replace a portion with a new path in only four of them.

To perform a replace, select the "Search & Replace" option and enter the replacement text. Set your search options, such as specific fields or case sensitive search, and select one or more of the results to target. Once you are ready click the Replace Checked button.

Be extremely careful when doing a replace, because there is no undo.

Problem

You want to automatically notify an additional ping service of an update to your weblog.

Solution

Add the notification service's ping URL to the list under the "Publicity/Remote Interfaces" section of the New Entry Defaults Settings tab.

Discussion

Notification services track which weblogs have been updated and when. This is achieved through alerts or "pings" to the service when they've been changed.

Movable Type has the built-in functionality to optionally ping these services with each new entry post. To manage these settings for a weblog, click the Settings button on the Weblog Toolbar, and go into the New Entry Defaults tab. Under the "Publicity/Remote Interfaces" section are the controls for specifying which services to notify.

The interface includes check boxes for the most common and popular notification services -- blogs (Yahoo!), weblogs.com, and Technorati. There is no need to look up their ping URL. Instead, simply check a box and MT will notify these services when a new post is made.

These are just three of the available services. MT gives you the ability to add additional services as you see fit.

Add the service's ping URL in the text area labeled "Others": one URL per line.

Note that the addition of each additional notification service will slow the publishing of each new entry as the system sends and verifies each ping sent.

Once you have made your settings click the Save Changes button.

Problem

You want to permit different HTML tags in your comment and TrackBack ping displays than what is allowed by default.

Solution

Create your own Sanitize specification.

Discussion

The default Sanitize specification does a good job of protecting your weblogs from malicious markup making its way into your layouts. It is generally recommended that you stick with the defaults unless you have good reason and are confident you understand the format of the sanitize specification as described here. Improper specification could result in a breach of your server's security.

The sanitize spec consists of HTML tag names separated by commas any permitted attributes that are separated by spaces. Let's look at a few examples:

 a href,b

This spec will permit a tags with the href attribute and b tags. As previously mentioned, you must specify any permitted attributes, such as href, for the a tag. All attributes are stripped by default.

 p,br/

This spec allows p and br tags. Note the / appended to the br tag in this example. Because of the tag-closing feature implemented in sanitization, the processor would insert an unnecessary and illegal </br> to the markup. Adding the / after the tag name tells the parser that this tag does not need a closing tag.

If you wish to allow a certain attribute for any HTML tag in which it might appear, use a * (asterisk) as the tag name, followed by the list of attributes. For instance:

 br/,p,blockquote,* style

This spec will allow any of the following tags.

 <br style="..." />
 <p style="..." />
 <blockquote style="...">

You must still explicitly list any tags that you want included. The asterisk just allows the attribute listed in any of those tags.

Problem

You want to make your Movable Type system more secure with suexec or cgiwrap.

Solution

Run the system under cgiwrap or suexec.

Discussion

cgiwrap and suexec are special tools on the web server that allow your CGI scripts to be executed as "you", rather than as the web server. This simplifies Movable Type installation, because you no longer have to set permissions on your weblog or db directories, although you still need to set the permissions on the CGI scripts themselves. It is also more secure, because your weblog directories will be writeable only by you.

You may need to check with your hosting provider or system adminstrator to determine if your server has either of these tools installed. Movable Type can make a guess as to whether it is supported while verifying requirements. When you run mt-check.cgi, under the line reporting the version of Perl on your server, look for a line that says

    (Probably) running under cgiwrap or suexec

This indicates that your server probably has cgiwrap or suexec installed. This is not a guarantee though.

To enable the heightened security that cgiwrap and suexec provide, add the following lines to your mt-config.cgi file:

    DBUmask 0022
    HTMLUmask 0022
    UploadUmask 0022
    DirUmask 0022

Explain what this does.

Problem

You want to improve the performance of Movable Type by eliminating the overhead of CGI.

Solution

Run Movable Type under mod_perl 1.x.

Discussion

mod_perl embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request.

Movable Type can run under mod_perl 1.x in either Registry mode or as a set of full-fledged handlers. Note that in order to run under mod_perl, you must have Apache::Request and Apache::Cookie installed; these modules comprise the libapreq distribution, which can be downloaded from CPAN.

Setting up MT under Registry is just like setting up any other CGI script under Registry; add the following to your httpd.conf:

    PerlModule Apache::Registry
    <Location /path/to/mt>
    SetHandler perl-script
    PerlHandler Apache::Registry
    Options +ExecCGI
    </Location>

You will need to host your mt-static files in another directory outside of /path/to/mt, just as if you had placed MT into the cgi-bin.

If you want even more speed, consider running Movable Type to run as a mod_perl handler. You will need to set up a handler for the main application and one for each of your public scripts.

  • 1. Set up your mt-static directory in a web-accessible path not under /mt/.
  • 2. Add the following to your httpd.conf:
        <Perl>
        use lib '/path/to/mt/lib';
        use lib '/path/to/mt/extlib';
        </Perl>
    
        PerlModule MT::App::CMS
        <Location /mt/app>
        SetHandler perl-script
        PerlHandler MT::App::CMS
        PerlSetVar MTConfig /path/to/mt-config.cgi
        </Location>
    
        PerlModule MT::App::Comments
        <Location /mt/comments>
        SetHandler perl-script
        PerlHandler MT::App::Comments
        PerlSetVar MTConfig /path/to/mt-config.cgi
        </Location>
    
        PerlModule MT::App::Trackback
        <Location /mt/trackback>
        SetHandler perl-script
        PerlHandler MT::App::Trackback
        PerlSetVar MTConfig /path/to/mt-config.cgi
        </Location>
    
        PerlModule MT::App::Search
        <Location /mt/search>
        SetHandler perl-script
        PerlHandler MT::App::Search
        PerlSetVar MTConfig /path/to/mt-config.cgi
        </Location>
    
        PerlModule Apache::XMLRPC::Lite
        PerlModule MT::XMLRPCServer
        <Location /mt/xmlrpc>
        SetHandler perl-script
        PerlHandler Apache::XMLRPC::Lite
        PerlSetVar dispatch_to "blogger, metaWeblog, mt"
        PerlSetVar MTConfig /path/to/mt-config.cgi
        </Location>

    Note that, as an alternative to the use lib statement above, you could also use

        PerlSetEnv PERL5LIB /path/to/mt/lib
  • 3. In your mt-config.cgi file, you will need to use the following settings:
        CGIPath http://my.server.com/mt/
        StaticWebPath /mt-static/
        AdminScript app
        CommentScript comments
        TrackbackScript trackback
        SearchScript search
        XMLRPCScript xmlrpc

    StaticWebPath should correspond to the URI you set when setting up your mt-static directory in Step 1.

    If you are using BerkeleyDB, you also need to add the following in addition to the lines above:

        DataSource /path/to/db

Problem

You need to configure Windows to recognize .cgi files as Perl scripts.

Solution

Add perl.exe to the Home Directory configuration of your IIS server and set it to handle files with a .cgi extension.

Discussion

While Movable Type can be configured to run with .pl extensions that the Windows IIS server will recognize as Perl scripts, it is recommended that MT scripts are run with .cgi like they are on Unix systems.

Setting up IIS to handle files with .cgi extension as Perl scripts requires adding a few configuration settings to the server's home directory. Follow these steps:

  • 1 Go into the Information Internet Services Administration console.

    From the Start menu navigate to the "Control Panel," then "Administrative Tools," and finally "Internet Information Services."

  • 2 Open the "Default Web Site" Properties.

    Using the navigation on the left-side, navigate through "Local Computer" to "Web Sites" and right-click over "Default Web Site." Choose "Properties."

  • 3 Add the Configuration Record to the Home Directory.

    Select the Home Directory tab, click Configuration and the Add button. Enter the following values in the form:

    • Executable: #c:\Perl\bin\perl.exe "%s" %s
    • Extension: #.cgi
    • Verbs > Limit to: #GET,HEAD,POST
    • Uncheck the box labeled "Check that file exists."

    Press the OK button when you have completed entering the configuration parameters.

Problem

You want to enable Scheduled Post services on your Movable Type System.

Solution

Install the run-periodic-tasks to run under cron or other similar system utility.

Discussion

To set up scheduled posting you need to be able to set up a "cron" job on the server. There a number of ways these services can be implemented and will vary depending on your server environment. Some hosting providers will allow one and not the other.

After you've set up post scheduling, when you save an entry with a post status of "Scheduled," it will be automatically picked up and published by the script when it runs.

Note that you need to use the field labeled "Authored On" on the Edit Entry screen to specify the time when the entry should go live.

cron

If you have shell access to a Unix server you can set up scheduled posting by editing your crontab, the table the cron utility uses to store its assignments:

    % crontab -e

Then add the following line:

    0,15,30,45 * * * * cd /path/to/mt/; ./tools/run-periodic-tasks

This instructs cron to run the script at zero, fifteen, thirty, and forty-five minutes after the hour, every hour. The asterisks are a way of telling cron to do this every hour, every day, every day of the week and month. Make sure you have exactly four asterisks separated by spaces.

/path/to/mt/ should be the path to your Movable Type application directory.

After that, just save the file, exiting your editor, and cron will report that it installed a new crontab.

cPanel

To set up scheduled posting through cPanel, follow these directions:

How do I get to this in cPanel?

In the box labeled "Command to run," enter the path to your Movable Type installation, followed by /tools/run-periodic-tasks:

     cd /path/to/mt/; ./tools/run-periodic-tasks

The timing options can be set to a schedule that suits you; however, it is not wise to run the script more often than about once every fifteen minutes, since it could bog down your server. We recommend the settings "Every fifteen minutes," "Every Hour," "Every Day," "Every Month," and "Every Weekday."

Windows

If Movable Type is running on a Windows server, you can create a scheduled task to achieve the same result. Use the following parameters for your task:

How do I get to this in Windows?

  • Name

    "Movable Type Tasks".

  • Run

    The run command should be the path and filename of your Perl interpreter (i.e., C:\Perl\bin\perl.exe), followed by tools\run-periodic-tasks.

  • Start In

    Should be the full path to your Movable Type directory. Example: C:\Inetpub\wwwroot\mt.

  • Schedule

    The timing options can be set to a schedule that suits you, however, it is not wise to run the script more often than about once every fifteen minutes, since it could bog down your server. We recommend a frequency between every fifteen minutes to once a day.

Problem

You want to extend Movable Type's functionality and install a plug-in.

Solution

Installing a basic plug-in requires you to place a file with an .pl extension into the plugins directory; however more advanced plug-ins may have additional steps.

Discussion

Plug-ins are Perl scripts with a .pl extension that reside in the subdirectory named plugins under the Movable Type application directory. (If you are running an older version of MT that was upgraded and have not installed a plug-in before, you may have to create this directory.) Each time MT is initialized, these files are loaded, which notifies the system of their existence and tells it how to execute their functionality.

Installing a basic plug-in is quite easy. Simply place the code in plugins. That's it. Only files with .pl extensions are considered plug-ins and are loaded automatically by the system.

Plug-ins do not need system execution privileges in order to operate. Be careful not to include any files that are not plug-ins, as MT will execute them when trying to load them into the system as plug-ins. Depending on what the particular script does, the results could yield strange warnings and error message -- or worse!

The topic of the plug-in listing should be introduced in recipe 0 along with a Plug-ins Listing screenshot and legend.

In recent versions of MT, functionality was introduced to list installed plugins, including links to settings and documentation. Note that it is not required for all plu-g-ins to register themselves to be listed. The absence of a plugin does not necessarily mean it was not installed properly. Many older plug-ins were written before this feature was even available.

Plug-ins are listed at both the system and weblog levels. The primary difference is in the settings. Plug-in settings can be made on a system or per-weblog basis or both. How settings are implemented will depend on each plug-in and the nature of its functionality.

To see the system-level listings of plug-ins, click the Plug-ins System Shortcuts on the Main Menu or the Plug-ins button in the System Toolbar. In a specific weblog, plug-ins are listed by going into Settings and selecting the Plug-ins tab.

More advanced plug-ins may require additional steps to install. Some plug-ins will split out their functionality into separate Perl modules. Others may require the use of a CPAN module or additional configuration. Check the plug-in's installation instructions for more detail.

Another issue to consider when installing plug-ins is that they are available to all weblogs hosted by this instance of MT. (Instance meaning sharing the same mt.cgi URL and configuration.) Installing a poorly-behaved plug-in could impact the operations of others on that system.

For most of the plug-ins available and in use, see the MT Plug-in Directory at http://www.sixapart.com/pronet/plugins/.

Put the following in the KB instead?

Testing and Debugging Plugin Installations

Once you install a plug-in you'll want to test that it works. Create a test template and give it a try. Most well documented plug-ins include a synopsis of their use. It's a good idea to use this sample code to stop any errors from being introduced. Once you've created and saved your test template, build a page and take a look at it in your browser to see if it worked.

Not everything goes as planned though.

These are some baseline tips to debugging (and hopefully fixing) a faulty plug-in installation.

MT is very good about trapping and displaying most error messages to your browser. These can provide valuable information such as missing libraries, permission problems, improper configurations, and errors in tags use. If the errors persist, note the exact error message and action, and remove the plug-in to see if the error messages stops.

Less critical are warning messages that are output while MT continues processing. These tend to be harmless and are typically a symptom of a poor programming practice in the plugins code. Warning messages are not always bad. Sometimes warning message are used by developers to output debugging messages.

The most difficult installation issue to handle is a plug-in that seemingly does nothing and yields no error or warnings messages to your browser. Begin by checking the system Activity Log for error messages generated by the plug-in. MT will trap every failed plug-in load and record related error messages. In a majority of cases this will provide you with clues or even the solution to your problem.

If you continue to have issues you can't resolve, utilize the Movable Type Support forums for help. See "Using the Community Forums".

Problems

You want to extend Movable Type and develop an extension to the base system.

Solutions

Six Apart provides numerous resources to get you started with developing including tutorials and MT source code documentation.

Discussion

Movable Type's open code base and APIs (Application Programmers Interface) make the browser-based tool quite flexible and easily modifiable, allowing it to adapt to any number of publishing applications. Here are some pointers to that will get you started.

Perl API

The Movable Type code is written in an object-oriented style and contains a well-documented Perl API that you can use in your own Perl programs. The documentation itself is in POD format and is contained within the .pm files. You can read this documentation from the shell using the perldoc command. For example:

    % cd <movable type directory>/lib
    % perldoc MT

Plugins API

A plug-in is a piece of software that extends the Movable Type publishing platform in one of a number of ways. A plug-in can create new Movable Type template tags or global filters, process entry text when it is being built, and install call-backs to process objects whenever database events occur.

Writing plug-ins requires some knowledge of Perl in addition to PHP for dynamic publishing plug-ins. Plug-in code can take advantage of the full range of the Movable Type API and any external libraries such as those found at Comprehensive Perl Archive Network (CPAN).

See "How to Write a Plugin" primer to get started.

PHP Plugins API

Movable Type's dynamic publishing mode supports plug-ins as well. The architecture is different, but should be familiar in some respects.

Two key components to the PHP-based dynamic publishing engine are the Smarty template package and Justin Vincent's ezSQL library.

The php subdirectory under Movable Type's main directory contains all the files and resources related to the dynamic publishing engine:

    mt/php/
           lib/      Native MT tags and modules
           extlib/   Third-party packages (ezSQL and Smarty)
           plugins/  Third-party MT/PHP plug-ins

Plug-in files should be placed in the plugins directory. To develop MT/PHP plug-ins, you should familiarize yourself with creating add-ons for Smarty. Custom blocks, functions, and modifiers are the basis for adding container tags, variable tags and global filters respectively for MT/PHP.

See the overview of the dynamic publishing architecture for more..

For more information on creating custom plug-ins for MT's PHP layer, refer to this article on our ProNet site.

There is also a wealth of information on how to write Smarty routines on the Smarty web site.

Problem

You want to integrate a remote system with Movable Type.

Solution

Use one of the supported web service protocols.

Discussion

Movable Type supports a number of means of remote systems integration.

Syndication

Before reviewing the "proper" web service protocols supported by Movable Type, it is worth mentioning the use of syndication for integrating Movable Type with other systems. Essentially syndication formats over the web (HTTP) are simple read-only web services. The most popular and widely deployed of these services are the RSS and Atom syndication formats. Both of these formats are represented in MT's default template sets and can be easily modified and extended using MT's template tags and engine.

BloggerAPI and Metaweb API

Movable Type supports two protocols, the BloggerAPI and the MetaWeblog API, which added features to the BloggerAPI. Both were early community efforts to encourage more client software development. These similar protocols are based on XML-RPC, a predecessor of SOAP, as the means of providing remote interface services.

See LINK for more information on Movable Type's support and extensions to the BloggerAPI and MetaWeblog API.

Need the URL where the XML-RPC protocol APIs will reside on 6A servers.

The Atom Publishing Protocol

While widely supported, the XML-RPC protocols couldn't adapt to the rapid pace of change in weblog software. Various incompatibilities and design shortcomings existed that made scaling, latency, authentication, and extensibility difficult and problematic.

To address many of the issues with the XML-RPC protocols, an effort to develop an application-level protocol for publishing and editing Web resources was formed as part of the Atom standardization effort.

The Atom Publishing Protocol (APP), as it was named, is still under development although its basic characteristics are fairly stable. Unlike the Blogger and MetaWeblog protocols, APP uses the Atom Syndication Format instead of the XML-RPC format.

tim, the last part there, 'extend messages like feeds,' is nonsensical, but i'm not sure how to fix it, since i'm not sure what you're trying to say.

The use of the Atom Syndication format creates a strong bond between syndicated content and Web services and lets both clients and servers easily extend messages like feeds.

Going forward as the standard solidifies, Movable Type will build upon The Atom Publishing Protocol for remote systems integration.

Where is the Movable Type Atom API interface or is it the same as TypePad?

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.