
How to hide a Drupal Views block
It's not always as easy as you'd think
How hard can it be?
For some people handling certain edge-cases it is harder than you'd think, if numerous questions on the Drupal forum and StackExchange are anything to go by. Worst of all many of those questions go unanswered or are, at best, incomplete.
Why hide a Views block?
There are numerous reasons to hide a block, but in my case I only wanted the block to be visible if it had content. The problem was I could still see the block title even when the block appeared empty.
How is it done?
Here are the steps I worked through recently to get that #@!&%$ block to finally disappear! I have labelled the red herrings so you can skip them if you're short on time, but they are definitely worth a read - they might not be red herrings for you.
Step 1 "Hide block..." setting

"You just tick the Hide Block setting, right?" well yes ... kinda. But first you have to find it. It is not on the Configure Block form, nor is it on the Default tab of the View. It is on the tab for the specific block you wish to hide ... in the Advanced section on the right (possibly needs to be clicked to display) ... riiiight at the bottom. Literally the last place you'd look.
I clicked the setting, saved the View (don't forget that bit), switched to the page and, hey presto ... the block title was still there! Clearly I needed to do something else...
Step 2 Block Settings (red herring)
Next I clicked the "Configure Block" contextual link to try the block settings. I had the "Override title" option ticket so unticked this and saved the block. No change.
Step 3 Contextual Filters (red herring)
I returned to my View settings to look for a likely culprit. I decided to dig into Contextual Filters because I had one on this View. I tested various alternatives for the "when the filter value is not available" setting, eventually removing the contextual filter altogether. Even without a contextual filter, the block title was still visible. Time to try something else...
Step 4 Custom javascript (red herring)
In my case the block I wanted to hide displayed a carousel of images. This carousel was configured and run from custom javascript. Custom code is always a good place to start when debugging; a mistake in Drupal core or a contrib module is likely to get picked up in development or soon after launch, an error in custom code is more likely. I debugged the custom code and tried various configurations, eventually removing the custom javascript completely so that my block would be a list of stationary images. But still the block title was visible.
Step 5 Filter out NULL (empty) values
At this point I came across a suggestion on the 31st comment on a Drupal forum question (I'm not exaggerating)! The suggestion was to apply an "is not empty (NOT NULL)" filter to the field being displayed on the View. I saved the View, returned to the page and the Block Title was no longer displayed. I double-checked in the markup inspector, just to be certain, but there was no trace of the block. Success!

Root of the issue
In my case this bug came down to an empty multi-value field; my node had a multi-value image field storing the items to show on the image carousel. Even though there were no images on this node, there was still an empty (NULL) value in the database.
Conclusion
- Tick "Hide block..." setting
- Filter out empty values
It's easy when you know how, and now I (and you) know how!