1 node.module node_page_view(Node $node)

Page callback: Displays a single node.

Parameters

Node $node: The node entity.

Return value

A page array suitable for use by backdrop_render().:

See also

node_menu()

File

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

Code

function node_page_view(Node $node) {
  // Determine if user has permission to view full page directly.
  // Display "page not found" if not.
  $type = node_type_get_type($node);
  $bypass_hidden_path = user_access('view hidden paths');
  if ($type->settings['hidden_path'] && !$bypass_hidden_path) {
    backdrop_not_found();
    backdrop_exit();
  }

  // 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.
  backdrop_set_title($node->title);
  // Set the node path as the canonical URL to prevent duplicate content.
  $uri = entity_uri('node', $node);
  $canonical_secure = config_get('system.core', 'canonical_secure') ? TRUE : FALSE;
  $uri_options = array('absolute' => TRUE, 'https' => $canonical_secure);
  backdrop_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], array_merge($uri['options'], $uri_options))), TRUE);

  // Show a message if the content type is configured to have a hidden path.
  if ($type->settings['hidden_path']) {
    $message = t('Only people with the <em>View hidden paths</em> permission will be able to view this page. Everyone else will receive a "Page not found" error.');
    backdrop_set_message($message, 'info');
  }

  return node_show($node);
}