You are here

function nodesymlinks_page in NodeSymlinks 7

Same name and namespace in other branches
  1. 6 nodesymlinks.module \nodesymlinks_page()

Main callback for displaying the node.

Menu callback which loads and displays the content from the node wrapped within the different menu and breadcrumbs. It also sets the robots META tag to prevent duplicate search engine indexing.

2 string references to 'nodesymlinks_page'
nodesymlinks_menu in ./nodesymlinks.module
Implements hook_menu().
nodesymlinks_menu_breadcrumb_alter in ./nodesymlinks.module
Implements hook_menu_breadcrumb_alter().

File

./nodesymlinks.module, line 138
Node Symlinks allows creating duplicate menu links with unique id to all nodes. As a result all these duplicates have unique menu trails and breadcrumbs.

Code

function nodesymlinks_page($node, $mid) {

  // View as a full page.
  if (module_exists('page_manager')) {

    // If there exists another handler for the node view use it, otherwise
    // fallback on the drupal core node view.
    module_load_include('inc', 'page_manager', '/plugins/tasks/node_view');
    $output = page_manager_node_view_page($node);
  }
  else {

    // If display suite’s 'View mode per node' is used,
    // select the correct view mode.
    $viewmode = empty($node->ds_switch) ? 'full' : $node->ds_switch;

    // For markup consistency with other pages, use node_view_multiple()
    // rather than node_view().
    $output = node_view_multiple(array(
      $node->nid => $node,
    ), $viewmode);

    // Update the history table, stating that this user viewed this node.
    node_tag_new($node);
  }

  // Without this, title of the page would be same as the link title
  // @See http://drupal.org/node/1226012
  // @TODO: Is there a better way?
  drupal_set_title($node->title);

  // Set the canonical URL to be that of the original node.
  $uri = entity_uri('node', $node);
  drupal_add_html_head_link(array(
    'rel' => 'canonical',
    'href' => url($uri['path'], $uri['options']),
  ), TRUE);

  // Set the shortlink URL to be the unaliased version of the symlink path.
  drupal_add_html_head_link(array(
    'rel' => 'shortlink',
    'href' => url('node/' . $node->nid . '/mid/' . $mid, array(
      'alias' => TRUE,
    )),
  ), TRUE);
  return $output;
}