diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 222d09a..07bec84 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -531,6 +531,11 @@ function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); $variables['block'] = (object) $variables['elements']['#block_config']; + // If the block title is configured to be hidden, set it to an empty string. + if (empty($variables['block']->display_title)) { + $variables['block']->hidden_title = $variables['block']->subject; + $variables['block']->subject = ''; + } // All blocks get an independent counter for each region. if (!isset($block_counter[$variables['block']->region])) { diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 9e5bf6c..496323a 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -76,8 +76,8 @@ public function getConfig() { $this->configuration += array('subject' => $definition['subject']); } } - // Ensure that the default cache mode is set. - $this->configuration += array('cache' => DRUPAL_NO_CACHE); + // Ensure that the default cache mode and title display is set. + $this->configuration += array('cache' => DRUPAL_NO_CACHE, 'display_title' => TRUE); return $this->configuration; } @@ -239,6 +239,12 @@ public function form($form, &$form_state) { '#title' => t('Title'), '#maxlength' => 255, '#default_value' => !$entity->isNew() ? $entity->label() : $definition['subject'], + '#required' => TRUE, + ); + $form['display_title'] = array( + '#type' => 'checkbox', + '#title' => t('Display title'), + '#default_value' => isset($this->configuration['display_title']) ? $this->configuration['display_title'] : TRUE, ); $form['machine_name'] = array( '#type' => 'machine_name',