Skip to main content

Manipulating User Input: The Filter System

  • Chapter
Pro Drupal Development
  • 353 Accesses

Abstract

Adding content to a web site can be quite a chore when you have to format the information yourself. Conversely, making text input look good on a web site requires knowledge of HTML—knowledge most users don’t want to be bothered with. For those of us who are HTML-savvy, it’s still a pain to stop and insert tags into our post during the middle of a brainstorm or literary breakthrough. Paragraph tags, link tags, break tags... yuck. The good news is that Drupal uses prebuilt routines called filters to make data entry easy and efficient. Filters perform text manipulations such as making URLs clickable, converting line breaks to < p> and < br /> tags, and even stripping out malicious HTML. hook_filter() is the mechanism behind filter creation and manipulation of user-submitted data. Filters are almost always a single action such as “strip out all hyperlinks,” “add a random image to this post,” or even “translate this into pirate-speak” (see pirate.module at http://drupal.org/project/pirate).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2007 John K. VanDyk and Matt Westgate

About this chapter

Cite this chapter

(2007). Manipulating User Input: The Filter System. In: Pro Drupal Development. Apress. https://doi.org/10.1007/978-1-4302-0190-8_11

Download citation

Publish with us

Policies and ethics