function comment_goodness_permalink in Comment goodness 7
Redirects comment links to the correct page depending on comment settings.
Since comments are paged there is no way to guarantee which page a comment appears on. Comment paging and threading settings may be changed at any time. With threaded comments, an individual comment may move between pages as comments can be added either before or after it in the overall discussion. Therefore we use a central routing function for comment links, which calculates the page number based on current comment settings and returns the full comment view with the pager set dynamically.
Parameters
$cid: A comment identifier.
Return value
The comment listing set to the page on which the comment appears.
See also
1 string reference to 'comment_goodness_permalink'
- comment_goodness_menu_alter in ./
comment_goodness.module - Implements hook_menu_alter().
File
- ./
comment_goodness.module, line 569 - Comment goodness provides newest to oldest comment sorting
Code
function comment_goodness_permalink($cid) {
if (($comment = comment_load($cid)) && ($node = node_load($comment->nid))) {
// Find the current display page for this comment.
$page = comment_goodness_get_display_page($comment->cid, $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);
}
return MENU_NOT_FOUND;
}