1.20.x 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

modules/node/node.module, line 2444
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);

  return node_show($node);
}