I have a custom implementation of hook_node_view() that changes the display of comments on every node. I would like to know how I can get the result of this improved hook_node_view() to be displayed on a separate page.

Each node should have its own comment page.

I have tried doing this with the Views module, but it seems bypassing hook_node_view(), which makes sense. So I'm still brainstorming on a way that can make this possible.


The Talk module shows the comments for a node in a tab added to the node page.

The talk module removes comments from the node page and puts them on a separate tab. This style of commenting is very popular on Wiki sites (usually called the "discussion" page) and on news websites where the goal is to separate user generated content from editorial content.

When installed this module will add a tab to the set of tabs at the top of a node view page like "View | Edit | Talk" and provides a link at the bottom of the node to go to the talk page and view comments.

If you need to do something similar, but on a completely different page, you can look at the code of the module to write similar code.
In short, apart from implementing hook_node_view(), the module implements hook_node_load() to set $node->comment to 0 (after saving its value in another node property). Then it calls comment_node_view() after temporary setting the values of the Drupal variables used from that function.

  global $conf;
  $clone = clone($node);
  $clone->comment = _talk_node_comment_value($clone);
  $recover = FALSE;
  if (array_key_exists('comment_form_location_' . $node->type, $conf)) {
    $original_setting = $conf['comment_form_location_' . $node->type];
    $recover = TRUE;
  $conf['comment_form_location_' . $node->type] = COMMENT_FORM_SEPARATE_PAGE;
  comment_node_view($clone, $view_mode, $langcode);
  if ($recover) {
    $conf['comment_form_location_' . $node->type] = $original_setting;
  else {
    unset($conf['comment_form_location_' . $node->type]);

  // Display comment summary
  $addcmnt = ((_talk_node_comment_value($node) == COMMENT_NODE_OPEN) && (($view_mode != "teaser") || variable_get('talk_addcmnt_teaser', TRUE)));  
  if ($addcmnt) {
    $links = $clone->content['links']['comment']['#links'];
    $node->content['links']['comment'] = array(
      '#theme' => 'links__node__comment__talk',
      '#attributes' => array(
        'class' => array('links', 'inline'),

    foreach ($links as $link) {
      if(talk_activated($node->type)) {
        if (isset($link['href']) && $link['href'] == 'node/' . $node->nid) {
          $link['href'] .= '/talk';
      $node->content['links']['comment']['#links'][] = $link;
  // Add the Talk link if user has access and it's not blank
  if (_talk_access($node) && strlen(variable_get('talk_link', '')) > 0) {
    $node->content['links']['comment']['#links'][] = array(
      'href' => 'node/' . $node->nid . '/talk',
      'title' => talk_title($node, 'link'),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.