View has no data but still displaying in block

Events happening in the community are now at Drupal community events on www.drupal.org.
tejaspmehta's picture

Hello All,

I was building one theme based on fusion theme. Now all elements are set properly. Now i have created a view which is displayed in block. View display images of particular node if that node has image in CCK filed. So i created view with argument as Node:nid and Provide default argument and Node ID from URL. This works fine for all those nodes which have images. But when any node do not have any image at that time it should not display. But my problem is it is displaying. I have attached screen-shot of how it looks.

Any solution for this, to stop completely displaying off that block when there is no image for that node.

Thank you

Tejas Mehta

AttachmentSize
Screenshot-1.png8.61 KB

Comments

try this: go to view/edit :

ddorian's picture

try this:
go to view/edit : you should have Row style : Fields click on the config button and click the Hide empty fields

i have already set Hide this

tejaspmehta's picture

i have already set Hide this field if Empty. And also applied your solution but still no result. It display same as like previous.

In your Filters, for the

thecodecutter's picture

In your Filters, for the image in CCK field, select 'Is not empty (NOT NULL)'

This is the correct answer.

merlinofchaos's picture

This is the correct answer.

yes this is true forgot i

ddorian's picture

yes this is true forgot i have used it

Thanks

minneapolisdan's picture

The filters suggestion worked great, thank you. For the others, selecting "is not empty" only appeared on my Drupal 7 site, not my Drupal 6 site. Drupal 6 only offered a True/False filter.

Yep :)

web-beest's picture

That worked for me :) Thanks!

try hiding the block using

drupaledmonk's picture

try hiding the block using blockname.tpl.php if it has not passed all the requirements. Ideally this is not the method to be followed.

Hello thecodecutter, I

tejaspmehta's picture

Hello thecodecutter,

I appreciate your answer but i do not get any such option in my filter.
When i added "Configure filter Content: Image (field_right_image_cck) - list" it asked me 2 options only. True and False. Nothing else as per your description.

Also it shows as -list instead of simple value.

Any other solution ? Also i can not use method of blockname.tpl.php which is suggested by f4k1r.

Thank you
Tejas Mehta

for example my filed is :

ddorian's picture

for example my filed is : (field_attach) - delta ( check the filter that has delta in the end)

Filtering 'is not empty (NOT

cossimo's picture

Filtering 'is not empty (NOT NULL)' on the field's delta is problematic for fields with multiple values in that it can cause the view to replicate for each instance of the delta. For example, I set up an image gallery view that uses one image field, containing multiple possible values. Filtering the view on the image field's delta, using the 'is not empty (NOT NULL)' operator causes the view to duplicate for each image in the field. (So if there are five images in the gallery, five copies of the view get displayed.)

I don't know if this is the best way to address this or not, but I solved the problem by filtering the field delta on 'is equal to' 0, because presumably in a multi-value field, there will always be a delta value of 0 somewhere in the array if there is data in the field.

Again, I don't know if my understanding of how the field delta works is spot on or not, but this solutions works.

Works!

Abelito's picture

Thanks, this worked for me for multi-valued fields "filtering the field delta on 'is equal to' 0."

-delta field are

tejaspmehta's picture

-delta field are node-reference fields. I have Image field already set in my cck with name right_image. Its not showing in - delta.

Similar issue

jbrauer's picture

I've seen a similar issue which at first I attributed to Context. Since then, however, I've tried this on several sites, using different themes etc. Each time I get the block printed even when it has no values. If it has a title that is printed otherwise just the empty block structure.

  • Tried multiple themes including Garland
  • Create a block view using a Node: Nid argument
  • Display a field that is empty for a given node, Taxonomy All Terms for example
  • In the row style as well as the field set it to hide empty fields

This block displays fine on nodes with taxonomy terms, however viewing a node with no terms assigned (and no records in the node_term table) displays the block title. This is displayed even in the preview without going to a page.

(Seems this should probably be an issue but posting here first in case anyone has feedback first)

Cool thanks - using a filter

squarecandy's picture

Cool thanks - using a filter for the field worked.
BTW I got this to work in D6 using the content: My Photo - list true filter. I have "list field" disabled on the image file field, but it still seems to return true if there is an image present on the node, and not if there was no file uploaded.

Yea, in D6 for whatever

ryan.ryan's picture

Yea, in D6 for whatever reason it to list true instead of a data is not empty filter. Just wanted to agree.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: