Define a Custom Views Area Handler Plugin for Drupal 8, Drupal 9

Last updated May 3, 2021
Module Development8.9.x/9.1.x

Area handler plugins are used to determine what is displayed in areas such as the header, footer, and empty text sections of a view. The handlers provided by core cover displaying result summaries, and allowing users to enter in HTML to display. They are already pretty versatile. However, they may require code knowledge to accomplish some specific tasks. If you'd like to have a more specialized area handler that can be reused across multiple views, you may want to look into defining a custom area handler plugin.

In this tutorial we'll:

  • Create a custom area handler plugin with settings that can be updated through the Views UI.
  • Use the new area handler plugin in a view.

By the end of this tutorial you should know how to define a custom area handler with settings and use it in Views.