Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Need the ability to detect if the View within the box was empty. For example, so the entire box can be omitted from the page in the block theme file.
Comment | File | Size | Author |
---|---|---|---|
#1 | Empty_View-1246544-1.patch | 644 bytes | mpotter |
Comments
Comment #1
mpotter CreditAttribution: mpotter commentedHere is the patch. It sets a field called $block->is_empty to TRUE if the underlying View did not return any results and if the user does not have edit access to the box (so the Edit Box link will still normally get shown).
To use this in your block TPL file, you can simple check to see if $block->is_empty is TRUE to decide whether to output the content of the block.
Note that this will not work properly if you are using views within a view.
Comment #2
tirdadc CreditAttribution: tirdadc commentedComment #3
tirdadc CreditAttribution: tirdadc commentedCommitted. Should have remembered this before the release!