Recommended releases

Download Released

Adds a "Hide block if the view output is empty" option to Views block displays in Backdrop CMS, matching the behavior available in Drupal 10.

Requirements

  • Backdrop CMS 1.x
  • Views module (core)

Installation

  1. Place this module in your modules directory (e.g. modules/views_hide_empty_block).
  2. Enable it at Administration → Modules (“Views Hide Empty Block”).

Usage

  1. Edit a view that has a Block display.
  2. Under the Block display, open the Other section.
  3. Click Hide block if the view output is empty (or the current Yes/No value).
  4. Set to Yes and save the view.

When the option is Yes, the block is not rendered at all when the view returns no results (the block placeholder does not appear in the layout). When No, the block is shown as before (with the “No results” text or empty output if configured).

How it works

This module uses hook_views_plugins_alter() to replace the core Views block display plugin with an extended class that adds the hide_block_if_empty option and, when enabled, returns no output when the view has no results so the layout does not display the block.

License

GPL-2.0-or-later