Filter
Input Formats and Filters
Drupal site adminstrators can determine which HTML tags users are allowed to when creating content in a site and which tags are disallowed. Input formats and filters are useful for the following reasons:
- if editors of a site expect writers to follow a style, they can have the CMS automatically strip out tags that will not need to be used in the content creation process.
- so that administrators don't have to worry about people adding malicious code to their site.
- as an extension to user management, giving trusted user groups access to some tags while denying access to those tags (while allowing a minumum set) to others
Some Terminology
HTML tags: words or acronyms usually surrounded by angle brackets. For example, the bold tag is <b>, and tags usually need to be opened and then closed, surrounding text. Bold text or text that looks like this is produced with the following code: <b>text that looks like this</b> The browser translates that code into bold-type.
Filters in Drupal refer to the list of HTML tags that can. So a filter with the list of tags that looks like <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> will allow (from left to right) link creation tags, emphasis (italic) tag, the strong (bold) tag, tag for citing documents, a tag for displaying computer code, unordered list, ordered list, list item, definition list, definition terms, and definition descriptions. With this filter enabled, Drupal will strip all other tags that people will try to insert.
An input format is a list of filters that Drupal will go through in order that they are arranged in the configuration. As an administrator, you can determine which input formats automatically apply to certain roles of users on your site.
Giving Users Permissions to the Input Formats
Bryght sites come with Filtered HTML, PHP something, and full HTML allowed as the choices for the site's users. Administrators can choose which user groups (i.e. roles) get access to which filters. To change the permissions:
- Login
- Click Administer » Site configuration » Input formats. You should see a list of input format in rows and roles in the columns.
- Click "configure" for the input format you wish to edit.
- For each row, check the box that corresponds to the input format and role you want to give access to that input format to.
Changing the Tags Allowed in an Input Format
- Click Administer » Site configuration » Input formats
- Find the row of the input format you want to change, then click the "configure" in that row.
- Click the Configure tab.
- It's likely that if you have HTML Filter enabled along with others, you will only see a configuration box for that filter, though some modules add filters that can also be configured.
- You can choose to either strip tags that do not appear in your list (see below) or escape all HTML tags.
- Escaping means that Drupal will display the tags in your browser as they were typed. In other words, it will appear to readers that the browser did not process the tags but merely displayed the code. This is useful if you want to create an input format that allows for displaying of HTML code, for example in a forum about web design.
- Edit the list of tags you would like to allow. Tags are listed separated by a space. If you selected "Escape" in the option above, this list will be ignored.
- editing the list changes the filter for just that input format. If you want to add or remove a tag for more than one input format, you have to follow these directions for each.
- Click "Save Configuration"
Creating a New Input Format
If the input formats supplied by default do not meet your requirements as an administrator, you can create a new one. (You can also edit existing input formats. See below.)
- Login
- Click Administer » Site configuration » Input formats
- Click the Add new input format tab
- Type in a descriptive (though short) name for your new input format
- Give the appropriate roles permission to the new input format. See "Giving Users Permissions to the Input Formats" above.
- Find the input format you just created, and click the "configure" link for that input format.
- Enable at least one filter in the input format. Enabling HTML Filter is usually recommended.
- Click "Save Configuration".
- See the instructions for "Changing the Tags Allowed in an Input Format" above if you need to change the filter within the input format.
Arranging Filters
You can tell Drupal to execute filters in the order you choose. Once you've enabled more than one filter, click the rearrange filters tab, and assign each filter a number value. Lower numbers mean they will go to the top of the list (i.e. executed first) and higher numbers will go further down the list (i.e. after the ones above it).
Glossary
The glossary module implements (unsurprisingly) a glossary function. The glossaries are based on created vocabularies. Links to glossary terms can be configured to display as a filter function. The existence of a glossary entry can be indicated by using acronym tags, an icon, or a superscript character.