By mherchel on
Hi,
I have a view that pulls data out of specific CCK fields of a node type, and displays these fields in a sidebar block on the node's page using the Node:nid argument (using the Node ID from URL option).
My problem is that I do not want the block to be displayed if I do not have any data in the CCK field. Currently, Drupal will display the block with no data.
Within Views, I tried going into the CCK field under the Fields section of the views display, and selected the option to "Hide if empty". However, that did not do the trick.
Does anyone have any ideas?
Thanks!
Comments
Could you try adding a filter
Could you try adding a filter to the View?
The current option you've selected will hide that field, but not the display. Since you're on a node/[nid] page, there *is* a node returned, even if it has empty fields.
Under filters, add a filter for the field (probably just one, to be safe) in question. Many fields will have an "is not empty (NULL)" option. This probably won't work for all field types.
Provided you have not filled in any empty text for your view, I think this takes care of it. Block views that have zero rows will not appear, but results with empty fields are still results.
Ryan Price
DrupalEasy Podcast
Ryan- You're a genius! That
Ryan-
You're a genius! That worked like a charm.
Thanks!
Premium component based Drupal themes
not quite working for me
I don't seem to have any fields for my view that have an option of "is not empty (NULL)" except the date, and therefore I still can't get the block to go away if there is nothing to show that's recent or hasn't occurred already.
(In my case, the block I'm trying to hide if empty is an "events" block with date, title, and body.)
I need date to filter that content in the block so past events don't show up. when I tried setting the date to "is not empty..." I get old events just showing up. Any suggestions?
To be honest I didn't quite understand why your solution works anyway.
Thanks.
Thank you for this great
Thank you for this great advice.
Thanks!
yeah, a drag to maintain an old site, but this works! thanks!
+1
+1
6 years later and this is still a great solution. Just wanted to give kudos for this!
+1 for this solution, also
+1 for this solution, also bailed me out of the issue!