Conditional Text Filtering
In the code sample above where a text filter is registered with Movable Type, a condition is defined under which text filtering is allowed. The call back determines whether or not the text filter can be selected by a user via the web interface. The callback is called with a single parameter, the type of the object being transformed. Allowable values for the object type are:
- "entry"
- "comment"
The callback should return "1" if filtering is allowed, and "0" otherwise.
# Will only allow the text filter to be applied to comments
sub transform_when {
my ($obj_type) = @_;
return 1 if $obj_type && ($obj_type eq 'comment');
}
This page is part of the Movable Type Developer Guide
- Previous Text Filter Handler
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.