1.20.x node.block.inc NodeBlock::getContent()

Sets block content on block view.

Overrides Block::getContent

File

modules/node/node.block.inc, line 62
A class that displays a particular node in a block.

Class

NodeBlock
@file A class that displays a particular node in a block.

Code

function getContent() {
  // Look for and load translated node if translations are available.
  if (module_exists('translation') && !empty($this->settings['translate'])) {
    $node = $this->loadTranslatedNode();
  }
  else {
    $node = node_load($this->settings['nid']);
  }

  // Prevent display of no access to the node.
  if (!node_access('view', $node)) {
    return;
  }

  // Use a clone of the node so we can hide the title safely.
  $clone = clone($node);

  // Hide node title if not required.
  if (empty($this->settings['leave_node_title'])) {
    $clone->title = '';
  }

  $content = node_view($clone, $this->settings['view_mode']);

  // Hide links if they've been suppressed.
  if (empty($this->settings['links'])) {
    $content['links']['#access'] = FALSE;
  }

  // Add author and date information settings.
  $content['#display_submitted'] = !empty($this->settings['display_submitted']);

  // Add theme hook suggestion.
  $content['#theme'] = 'node__block_' . $this->settings['nid'];

  return $content;
}