From 5732629af8b60642fbe328bea65774497147a614 Mon Sep 17 00:00:00 2001
Date: Tue, 21 Sep 2010 15:02:52 +0200
Subject: [PATCH] Bugfix: module cck_blocks shows a block even if a field has no content.

---
 sites/all/modules/cck_blocks/cck_blocks.module |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/sites/all/modules/cck_blocks/cck_blocks.module b/sites/all/modules/cck_blocks/cck_blocks.module
index ff9df37..8470f2f 100644
--- a/sites/all/modules/cck_blocks/cck_blocks.module
+++ b/sites/all/modules/cck_blocks/cck_blocks.module
@@ -115,15 +115,19 @@ function cck_blocks_block($op = 'list', $delta = 0, $edit = array()) {
             $block['title'] = token_replace($title,'node',$built_nodes[$nid]);
           }
         }
-
-        /* Use the label of the field as the block's title. Only visible,
-         * if the user did not enter a custom title for the block as $block->subject
-         *  is replaced by $block->title (if set) in block_list().
-         */
-        $block['subject'] = t($fields[$delta]['widget']['label']);
-
-        // Set the field's data as the content of the block
-        $block['content'] = drupal_render($cck_field_data);
+        
+        $block_content = drupal_render($cck_field_data);
+        if (trim($block_content) != '') {
+          /* Use the label of the field as the block's title. Only visible,
+           * if the user did not enter a custom title for the block as $block->subject
+           *  is replaced by $block->title (if set) in block_list().
+           */
+          $block['subject'] = t($fields[$delta]['widget']['label']);
+  
+          // Set the field's data as the content of the block
+          $block['content'] = $block_content;
+        }
+        
       }
     }
   }
@@ -175,4 +179,4 @@ function cck_blocks_field_settings_submit($form, $form_state) {
   $field_name = $form['#field']['field_name'];
   $global_value = $form_state['values']['global_cck_blocks_settings'];
   variable_set('cck_blocks_' . $field_name . '_block_availability', $global_value);
-}
\ No newline at end of file
+}
-- 
1.7.0.4

