function node_page_view

Page callback: Displays a single node.

Parameters

\Drupal\Core\Entity\EntityInterface $node: The node entity.

Return value

A page array suitable for use by drupal_render().

See also

node_menu()

1 string reference to 'node_page_view'
node_menu in drupal/core/modules/node/node.module
Implements hook_menu().

File

drupal/core/modules/node/node.module, line 2162
The core module that allows content to be submitted to the site.

Code

function node_page_view(EntityInterface $node) {

  // If there is a menu link to this node, the link becomes the last part
  // of the active trail, and the link name becomes the page title.
  // Thus, we must explicitly set the page title to be the node title.
  drupal_set_title($node
    ->label());
  foreach ($node
    ->uriRelationships() as $rel) {
    $uri = $node
      ->uri($rel);

    // Set the node path as the canonical URL to prevent duplicate content.
    drupal_add_html_head_link(array(
      'rel' => $rel,
      'href' => url($uri['path'], $uri['options']),
    ), TRUE);
    if ($rel == 'canonical') {

      // Set the non-aliased canonical path as a default shortlink.
      drupal_add_html_head_link(array(
        'rel' => 'shortlink',
        'href' => url($uri['path'], array_merge($uri['options'], array(
          'alias' => TRUE,
        ))),
      ), TRUE);
    }
  }
  return node_show($node);
}