If I create a basic view (one argument, NID from URL, and one field, a FileField), and then create a block display, I expect the block to be hidden if the view returns no results. This works correctly if I have not set a title for the view. However, if I set a title for the view (or if I set a title for the block by configuring the block directly), the block always displays, regardless of whether the view is empty or not.

CommentFileSizeAuthor
#6 Screen shot 2012-03-22 at 11.23.18 AM.png24.05 KBfxarte

Comments

merlinofchaos’s picture

Status: Active » Closed (cannot reproduce)

I am unable to reproduce this behavior. An empty view does not show, with or without a title.

Note: If you're using a field api field, please be sure that the view is truly empty. Empty does not mean "No visible fields", empty means "No rows returned". It's possible to have rows with no visible results. Views can't tell that is the case, and therefore you have blocks that you think are empty, but are in fact not empty in Views' eyes.

danepowell’s picture

Just FYI, I solved the problem by adding a filter for "Fields: field_files - fid (not empty)" - apparently, if a File field is "empty", it's not really "empty"? Doesn't make sense to me, but anyway, it fixed the problem.

merlinofchaos’s picture

Remember, just because fields are empty that does not mean that no results were returned. Nodes with empty fields are still nodes, even if none of the fields you selected contain data.

danepowell’s picture

Doh, of course... thanks for taking the time to explain it

knalstaaf’s picture

#2 worked for me as well, thanks for sharing! Had to set the operator of that field to "Is not empty (NOT NULL)".

My case (in Filter Criteria):

Content: YouFieldName:fid (not empty)

EDIT: Doesn't work for my jQfx Views Galleria. It places its thumbs about 3 times (multiple rows of the same thumbs).

fxarte’s picture

StatusFileSize
new24.05 KB

You need to go to your Contextual filter options and way down and inside the more option group, check "exclude".
exclude argument from results
This will change the query views build from:

WHERE 
    (( (node.nid = '10' ) )
    AND(( (node.status = '1') 
    AND (node.type IN  ('page')) )))
ORDER BY node_created DESC

to

WHERE 
    (( (node.nid != '10' OR node.nid IS NULL) )
        AND(( (node.status = '1') 
    AND (node.type IN  ('municipality')) )))
ORDER BY node_created DESC