This seems like a very basic question, but I can't seem to find any info in the docs or forum.
I have a view that potentially may have no results. I want to insert this view as a block in a layout, but I only want the title to appear if the view actually has results.
It seems that if I set the "Block title type" to either "Default" or "Custom", the title (i.e. the view title or the custom title defined in the block, respectively) always appears, regardless of whether the view has results or not.
Is there any way to change this behavior? I'd be fine with having "Default" give the view title, but only if the view actually has results.
Comments
How are you generating the View?
There are a few ways to do it... but it depends on how you generate your View.
Are you using Contextual Filters?
You could use the "no results" option and add the title there, rather than using the "title" of the view...
Hmm... this is not the behavior I'm seeing.
2. I place this block in the Default layout with "Default" title
3. When I visit any page, IF I have posts the view shows the title:
4. But if I delete ALL Posts (forcing an empty View) I get this:
I wonder if perhaps your view has something in the Header field (like a Text Area)? If so, be sure that you unclick "Display even if view has no result".
Here are some more details about my setup. Yes, I am using a contextual filter.
Specifically, I have several content types that have an entity reference field meant to hold references to content that is related to that node. I want to be able to display teasers of those related nodes as a grid.
Below are some screen shots of my configuration.
Note that the "Gallery views" views block suffers from the same problem. It involves a contextual filter but not entity references.
My desired result is that in a case like this, the two titles at the bottom should not appear.
Is this related to the contextual filter somehow? I'm still quite confused by the details of how contextual filters work.
Of course, I could just display the contents of the entity reference field directly. But I'd like them to be laid out as a grid, and I'm not sure how to do that easily through "Manage Displays". If there is, then that would obviously solve my problem.