3

On a page, a views block should show some text on top of the view when the block doesn't hide and there is content to show: <h4>Title <span class="dot white">•</span></h4>. Now, when there is no content in the block, this text should be hidden. I've tried to do this with putting the header in the view as 'unfiltered text' in 'header' and then setting the view to hide when there's no content. This doesn't work or could it be that I'm doing something wrong?

Update, I got it to work, and think the following is happening: It is possible to just put this text in the header of the view as 'unfiltered text' in 'header' and it will hide when there are no results. However, when the view is based on a taxonomy relationship as it was with mine, and 'require this relationship' is not set, there will always be a result, so the header will show eventhough those results are filtered away.

0

1 Answer 1

2

Well I think you are asking how to hide a block view completely when it is inserted as a global: view area in the header of another view.

For the parent view:

When inserting the block view into the header of another view, make sure you leave the box unchecked that says: Display even if view has no result

enter image description here

For the block view that is being inserted check these 3 things:

1: If you are displaying fields in the block view, you want first make sure you are hiding any empty fields under Show: Fields | Settings

enter image description here

2: Then you want make sure you you have the Hide block if the view output is empty: set to yes under the advanced tab in the block view.

enter image description here

3: You also want to add a contextual filter for the block view that defines the context you want. Then set the WHEN THE FILTER VALUE IS NOT AVAILABLE setting to hide view. (For the image below, my context needed was taxonomy term ID.)

enter image description here

Hope this helps!

3
  • Thank you for your elaborate instructions! I've managed to achieve the showing and hiding of the header using this technique, but don't you think there must be a better way? The only thing I would like to do is just put some text on top of the view when the block doesn't hide and there is content to show. I will edit my question to be more distinct
    – C.A. Vuyk
    Commented Dec 25, 2019 at 9:16
  • You should be able to just add that text as a header message in the block view that is being hidden, and when there are no results for the view, the message in the header will be hidden as well. Are you inserting a view in another view, or just trying to accomplish this with one view? Commented Dec 25, 2019 at 13:00
  • Yes, you're right. I was just doing this with one view. When the view is based on a relationship as it was with mine, and 'require this relationship' was not set, there would still always be a result. (see update)
    – C.A. Vuyk
    Commented Dec 25, 2019 at 17:09

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.