I have a view block and - because of the filters being applied - it may show data or may not. If the view's query returns no results, I need to hide the entire block - the .block - not just the .view or .view-content. I've seen several other questions and pages that offer solutions but all either don't hide the entire .block or just flat out don't work.

The solution that appears to be most discussed uses the Global: Null contextual filter, but that always hides the entire block regardless of any other condition. In fact, it doesn't even run the query when this filter is active. I need the block to be hidden if and only if the query returns no results.

I have the default, barebones Drupal 7 installed with only Bartik, CTools and Views so I am sure there aren't any other conflicts coming in from the theme or other modules.

  • did you ever find a solution for this?
    – Randell
    Jan 23, 2019 at 3:35
  • @Randell Sorry. I cant recall. I don't even remember what site I was working on back then.
    – Jeff
    Jan 23, 2019 at 21:58

1 Answer 1


One of the solution is:

Under FIELDS: click each field and in the "No results text" area, check the "hide if empty" box.

This will allow the field not to show if there is nothing actually there to show. But will not affect how the block itself displays on the page.

Another solution for this is :

  1. Go to the advanced tab of you view
  2. Add contextual filters
  3. Select Global: Null
  4. When the filter value is NOT available: Select 'Hide view'

enter image description here

enter image description here

  • 1
    Thanks for the answer. As I stated in my question, when I attempt this solution, the block is ALWAYS hidden. I only want the block to be hidden when the query returns no data. Can you confirm that this solution will only hide the block when the query returns no results?
    – Jeff
    May 28, 2015 at 13:39
  • ummm...i am also not so sure about this may be you can try the first solution also that i have mentioned
    – Sidharth
    May 28, 2015 at 14:16
  • Unfortunately,no. The first suggestion does not hide the whole block.
    – Jeff
    May 28, 2015 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.