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 is part of the Movable Type Developer Guide

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

1 Note

Helpful, but the 'Event Handlers' information that follows this can be quite confusing to users - it goes right into presavefilter - close, but different than pre_save.

For clarity these two should be consistent, or make it very clear that the handler is not for this event.

Leave a note

Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.