diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc index f0e999d..bb44ca5 100644 --- a/modules/block/block.admin.inc +++ b/modules/block/block.admin.inc @@ -277,6 +277,11 @@ function block_admin_configure($form, &$form_state, $module, $delta) { '#default_value' => isset($block->title) ? $block->title : '', '#weight' => -19, ); + $form['settings']['label_display'] = array( + '#type' => 'checkbox', + '#title' => t('Display title'), + '#default_value' => isset($block->label_display) ? $block->label_display : BLOCK_LABEL_VISIBLE, + ); // Module-specific block configuration. if ($settings = module_invoke($block->module, 'block_configure', $block->delta)) { @@ -473,6 +478,7 @@ function block_admin_configure_submit($form, &$form_state) { 'pages' => trim($form_state['values']['pages']), 'custom' => (int) $form_state['values']['custom'], 'title' => $form_state['values']['title'], + 'label_display' => $form_state['values']['label_display'], )) ->condition('module', $form_state['values']['module']) ->condition('delta', $form_state['values']['delta']) @@ -561,7 +567,7 @@ function block_add_block_form_submit($form, &$form_state) { // Store block delta to allow other modules to work with new block. $form_state['values']['delta'] = $delta; - $query = db_insert('block')->fields(array('visibility', 'pages', 'custom', 'title', 'module', 'theme', 'status', 'weight', 'delta', 'cache')); + $query = db_insert('block')->fields(array('visibility', 'pages', 'custom', 'title', 'label_display', 'module', 'theme', 'status', 'weight', 'delta', 'cache')); foreach (list_themes() as $key => $theme) { if ($theme->status) { $query->values(array( @@ -569,6 +575,7 @@ function block_add_block_form_submit($form, &$form_state) { 'pages' => trim($form_state['values']['pages']), 'custom' => (int) $form_state['values']['custom'], 'title' => $form_state['values']['title'], + 'label_display' => $form_state['values']['label_display'], 'module' => $form_state['values']['module'], 'theme' => $theme->name, 'status' => 0, diff --git a/modules/block/block.install b/modules/block/block.install index d8eab18..cac7f4a 100644 --- a/modules/block/block.install +++ b/modules/block/block.install @@ -85,6 +85,13 @@ function block_schema() { 'description' => 'Custom title for the block. (Empty string will use block default title, will remove the title, text will cause block to use specified title.)', 'translatable' => TRUE, ), + 'label_display' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + 'size' => 'tiny', + 'description' => 'Flag to indicate display of block title, currently just boolean. (0: hidden, 1: visible)', + ), 'cache' => array( 'type' => 'int', 'not null' => TRUE, @@ -489,5 +496,18 @@ function block_update_7009() { } /** + * Add label_display field to block table. + */ +function block_update_7010() { + db_add_field('block', 'label_display', array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + 'size' => 'tiny', + 'description' => 'Boolean to indicate whether to display block title.', + )); +} + +/** * @} End of "addtogroup updates-7.x-extra". */ diff --git a/modules/block/block.module b/modules/block/block.module index 48c80d7..8f39713 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -41,6 +41,16 @@ define('BLOCK_VISIBILITY_LISTED', 1); define('BLOCK_VISIBILITY_PHP', 2); /** + * Indicates the block label (title) should be hidden from end users. + */ + define('BLOCK_LABEL_HIDDEN', 0); + +/** + * Indicates the block label (title) should be displayed to end users. + */ + define('BLOCK_LABEL_VISIBLE', 1); + +/** * Implements hook_help(). */ function block_help($path, $arg) { @@ -1035,6 +1045,16 @@ function template_preprocess_block(&$variables) { // Create a valid HTML ID and make sure it is unique. $variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta); + + // If the block title is configured to be hidden, set a class on title. + if(isset($variables['block'])) { + $variable_block = $variables['block']; + if(isset($variable_block->label_display)) { + if (!$variables['block']->label_display) { + $variables['title_attributes_array']['class'][] = 'element-invisible'; + } + } + } } /**