Hide Empty View: Block Display

Christina

Have you had this happen to you?

You create a great block display in Views. You configure it just right for your pages and then, it shows up, or part of it does, on pages where there is no content to fill it? As a relative newbie to Drupal Views, this stumped me for a bit. Fortunately there is an easy fix right in Views.

The How To:  (you can do either or both parts depending upon what you need to accomplish).

Part 1.

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.

AND

Part 2.

Under Contextual filters: you want to Add Global:Null and set "When the filter value is NOT available" and click "display all results for the specified field".

This will hide the block from the page if there are no contents.

Make sure to Apply to your display and then Save the view.

Disqus Comments