Views Block Exposed Filter Blocks
Enables exposed filters on Views block displays to be placed as separate, independent blocks.
views_block_filter_block
Install
composer require 'drupal/views_block_filter_block:^2.1'
Overview
Views Block Exposed Filter Blocks is a utility module that extends Drupal's Views functionality by allowing exposed filters on block display views to be rendered and placed as standard blocks. By default in Drupal core, this "Exposed form in block" functionality is only available for page display views, not block display views.
Once installed, this module requires no additional configuration. It automatically adds an "Exposed form in block" option under the "Advanced" pane in the Views UI for all block display views. When enabled for a specific view block, a new block becomes available in the Block layout system that contains just the exposed filters for that view, allowing site builders to place the filter form anywhere on the page, separate from the view results.
The module works by extending the ctools_views Block display plugin and overriding key methods to enable exposed form rendering in blocks. It also modifies the reset button visibility on exposed forms to only show when there are visible filter elements.
Features
- Enables 'Exposed form in block' option for Views block displays, which is normally only available for page displays
- Creates a separate placeable block containing only the exposed filters for a view block display
- Automatically shows/hides the reset button based on whether there are visible filter elements
- Zero configuration required - works immediately after installation
- Integrates seamlessly with Views UI under the Advanced section
Use Cases
Placing exposed filters in a sidebar
When you have a Views block displaying content in the main content area, you may want the exposed filters (like category dropdowns or keyword search) to appear in a sidebar. This module allows you to place the exposed filter form as a separate block in any region while the view results remain in the main content area.
Creating a search page with AJAX-enabled view blocks
For an e-commerce or product listing page using Views blocks, you can place the filter/facet form in a prominent location (like above the products or in a collapsible panel) while the product grid updates via AJAX when filters are applied.
Multi-filter landing pages
Create a landing page where multiple Views blocks share a common filter block. The exposed filter form can be placed once at the top of the page, and it will filter the associated view block wherever it is displayed on the page.
Mobile-friendly filter placement
Place the exposed filter block in a location that works better for mobile layouts, such as in a slide-out menu or collapsible section, while keeping the view results in the main content flow.
Tips
- The exposed filter block will be named 'Exposed form: [view_machine_name]-[display_id]' in the block library
- You can use CSS to style the exposed filter block independently from the view results
- Consider using AJAX on your Views block for a smoother user experience when filters are applied
- The module works with contextual filters and regular exposed filters
Technical Details
Hooks 3
hook_views_plugins_display_alter
Alters the Views display plugins to replace the default block display class with the module's custom ViewsBlockFilterBlockPluginDisplayBlock class, which enables exposed form rendering in blocks.
hook_form_views_exposed_form_alter
Alters the Views exposed form to control the visibility of the reset button. The reset button is only shown when there are visible filter elements in the form.
hook_help
Provides help text for the module on the admin/help page, explaining the module's purpose and functionality.
Troubleshooting 4
Ensure the module is properly enabled. Check that you are editing a Block display (not a Page display). The option appears under Advanced > Other in the Views UI.
After enabling 'Exposed form in block' for a view, you must save the view. Then navigate to Structure > Block layout and look for a block named 'Exposed form: [view_name]-[display_id]'.
If upgrading from an earlier version, run database updates (drush updb) to trigger the update hook that installs ctools_views. Alternatively, manually enable ctools_views before enabling this module.
The reset button only appears when there are visible filter elements. If all your filters are hidden or have no options, the reset button will be hidden. This is intentional behavior to avoid showing a reset button with nothing to reset.