You are here

function talk_permalink in Talk 7

Page callback for talk view page.

1 string reference to 'talk_permalink'
talk_menu_alter in ./talk.module

File

./talk.module, line 51
Comments are displayed in a separate 'talk' tab, for node types you wish

Code

function talk_permalink($cid) {
  if (($comment = comment_load($cid)) && ($node = node_load($comment->nid))) {

    // Find the current display page for this comment.
    $page = comment_get_display_page($comment->cid, $node->type);
    if (!talk_activated($node->type)) {

      // Set $_GET['q'] and $_GET['page'] ourselves so that the node callback
      // behaves as it would when visiting the page directly.
      $_GET['q'] = 'node/' . $node->nid;
      $_GET['page'] = $page;

      // Return the node view, this will show the correct comment in context.
      return menu_execute_active_handler('node/' . $node->nid, FALSE);
    }
    else {
      drupal_goto("node/{$node->nid}/talk/{$comment->nid}", array(
        'fragment' => "comment-{$comment->cid}",
      ), 301);
    }
  }
  return MENU_NOT_FOUND;
}