Views global filters
Views Global Filter is a contributed Drupal 6 and 7 module that applies one visitor filter choice to several views. It has no Drupal 11 release.
With Views Global Filter, a visitor picks a value, such as a country, once, and the module passes it invisibly as a contextual filter to every view the site builder chose. It is not part of Drupal core Views. In Drupal 11 you use core parts instead, and you set them on each view: exposed filters, a remembered selection and contextual filters.
The Global group in the Views UI is something else. It lists core handlers such as the Combine fields filter, which combines several fields and searches them together.
What the module does
The project page describes the idea as "picked once, operates site-wide". The 7.x version supports both fields and Views and offers several selection widgets. The selected value is stored in the session, a cookie or the database. The project page shows it last updated on 4 December 2015 and says there are no supported stable releases.
The project has an 8.x-1.0-alpha0 release, and its release notes say it holds only an info file. Its release list shows no 9.x, 10.x or 11.x version. A tutorial that tells you to install it on Drupal 11 is wrong: there is no release to install.
What to use in Drupal 11
Combine these core parts as the job needs.
- Remember the selection. An exposed filter has the option Remember the last selection. The Views source describes remembered exposed input as stored in the session.
- Move the form. For a display with a path, Exposed form in block puts the filter form in a block that you place yourself.
- Read a value from the address. Each exposed filter has an identifier that appears in the URL after the question mark. A contextual filter can take its default value from a query parameter, which is a named value in that part of the address.
Example
A site has two views, one for events and one for partners. Both content types have a Region list field with keys such as emea. Expose a region filter on the events page with the identifier region. On the partners view, add a contextual filter on the region field and choose Provide default value, then Query parameter, with the parameter name region. A link such as /partners?region=emea now filters the partners view, because it reads the region from the address.
Common mistakes
- Expecting one setting for all views. Remembering a selection and exposing a filter are set on each view.
- Forgetting anonymous visitors. The remember option stores nothing for roles you did not select, and by default only the authenticated role is selected.
For marketing and content teams
If you want a visitor's choice, such as a region, language of interest or product line, to carry across pages, write that requirement down with the pages involved. Your developer can then pick between a remembered selection, a link that carries the value in the address, or a custom solution.
Sources
- Drupal.org project: Views Global Filter (global_filter)
- Drupal.org project: Global Filter releases
- Drupal.org project: Global Filter 8.x-1.0-alpha0 release
- Drupal core: FilterPluginBase.php
- Drupal core: HandlerBase.php
- Drupal core: DisplayPluginBase.php
- Drupal core: QueryParameter.php contextual filter default
- Drupal core: ViewsViewsHooks.php (Global group)
- Drupal.org documentation: Add a contextual filter to a view