Registering Callbacks

To register a callback for an event in Movable Type, you will need to make changes to your config.yaml. You will need to have on hand two things:

  • the name of the event you are listening for
  • the package name and subroutine name to be invoked when the event occurs

For example, to register a callback for the MT::Entry pre_save event, use the following config.yaml:

name: Example Plugin for Movable Type
id: Example
description: This plugin is an example plugin for Movable Type.
version: 1.0
callbacks:
    MT::Entry::pre_save: $Example::Example::Plugin::entry_pre_save

You will then need to add an event handler or callback function to your Plugin.pm file.

Tip: Registering Any-Class Object-level Callbacks

Developers can also register callbacks for all pre_save events by using a wildcard like so:

name: Example Plugin for Movable Type
id: Example
description: This plugin is an example plugin for Movable Type.
version: 1.0
callbacks:
    '*::pre_save': $Example::Example::Plugin::entry_pre_save

"Any-class" callbacks are called after all class-specific callbacks.

This page was last updated on 2008-09-17, 14:41.  

Leave a note

Have a question, please use the MT Forums. Notes sumbitted here should pertain to tips & hints regarding documentation. Your note may be removed once it's contents has be integrated into the body of the page.