Moodle filters modify content from the database as it is output to the screen, thus adding function to the display. An example of this is the multimedia filter, which can detect references to video and audio files, and can replace them with a "mini-player" embedded in the content. This chapter will cover the basic concepts of creating a Moodle filter, which includes:
How a filter works
Using the API to create filter code
How to use language files
How to create configuration settings
Before trying to build a filter, it would help to understand how it works. To begin with, any text written to the screen in Moodle should be processed through the format_text
function. The purpose of this function is to process the text, such that it is always safe to be displayed. This means making sure there are no security issues and that any HTML used contains only allowed tags.
Additionally, the output is run through the filter_text
function, and...