You are here

function title_preprocess_node in Title 8.2

Implements hook_preprocess_node().

File

./title.module, line 111
Convert titles into fields which can be display manipulated.

Code

function title_preprocess_node(&$variables) {

  // Restore the title field in the content array if display is being managed
  // and is not hidden.
  $config = \Drupal::service('title.config_manager');
  if (!empty($variables['label']) && $config
    ->getEnabled($variables['node']
    ->bundle())) {
    if (!isset($variables['label']['#title_hidden'])) {
      $variables['content']['title'] = $variables['label'];
    }

    // The only way to hide the title in the core node template.
    $variables['page'] = TRUE;

    // Since titles are rendered in a block, they are pulled out of the page
    // and rendered, setting #printed to TRUE.
    // @see \Drupal\Core\Entity\Controller\EntityViewController::buildTitle.
    if ($variables['view_mode'] == 'full' && isset($variables['content']['title'])) {

      // @todo, find a way to deal with titles on full page views now that
      // the title is in a block.
      // $variables['content']['title']['#printed'] = FALSE;
    }
  }
}