Name

registerFilter() — dynamically register filters

Description

void registerFilter(string type,
                    mixed callback);

Use this to dynamically register filters to operate on a templates. It uses the following parameters:

  • type defines the type of the filter. Valid values are "pre", "post", "output" and "variable".

  • callback defines the PHP callback. it can be either:

    • A string containing the function name

    • An array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the method-name

    • An array of the form array($class, $method) with $class being the class name and $method being a method of the class.

Technical Note

If the chosen function callback is of the form array(&$object, $method), only one instance of the same class and with the same $method can be registered. The latest registered function callback will be used in such a scenario.

A prefilter runs through the template source before it gets compiled. See template prefilters for more information on how to setup a prefiltering function.

A postfilter runs through the template code after it was compiled to PHP. See template postfilters for more information on how to setup a postfiltering function.

A outputfilter operates on a template's output before it is displayed. See template output filters for more information on how to set up an output filter function.

See also unregisterFilter(), loadFilter(), $autoload_filters, template pre filters template post filters template output filters section.

    Поддержать сайт на родительском проекте КГБ