Add a contextual filter to a view

Last updated on
5 July 2017


You can configure a view so that it is filtered dynamically, depending on the context. For example, you could use a contextual filter to add a block that contains related content or that presents a list of articles by the same author.

Prerequisite: To create a contextual filter that is based on a context other than the information in the URL, you may need to create a relationship. For more information, see Add a Relationship to a View.

  1. Navigate to the edit screen of a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
  2. Click Advanced.
  3. In the Contextual Filters area, click Add.
  4. From the Add Contextual Filters list, select one or more filters and click Apply and Configure Contextual Filters. The Configure Contextual Filter dialog box displays.
  5. In the When the Filter Value is Not Available section, specify one of the following options:
    • Display all results for the specified field
    • Provide default value
    • Hide view
    • Display a summary
    • Display contents of "No Results Found"
    • Display "Access Denied"
  6. If you want to specify a different behaviour for certain situations, in the Exceptions section, specify a value for exceptions.
  7. In the When the Filter Value is Available or a Default is Provided section, specify one of the following options:
    • Override title
    • Override breadcrumb
    • Specify validation criteria
  8. Click Apply and Continue. Repeat steps 5 through 7 for each selected filter.