Index: comment_display.module =================================================================== --- comment_display.module (Revision 387) +++ comment_display.module (Arbeitskopie) @@ -29,7 +29,7 @@ function comment_display_node_show($node } $output = node_view($node, FALSE, TRUE); - // Note: Output of comments moved into comment_display_preprocess_page(). + // Note: Output of comments moved into comment_display(). // Update the history table, stating that this user viewed this node. node_tag_new($node->nid); @@ -54,9 +54,51 @@ function comment_display_node_page_view( */ function comment_display_preprocess_page(&$vars) { $vars['comments'] = ''; - if (function_exists('comment_render') && !empty($vars['node']) && $vars['node']->comment) { + if (!empty($vars['node'])) { + $vars['comments'] .= comment_display($vars['node']); + } +} + +/** + * Implementation of hook_block(). + */ +function comment_display_block($op = 'list', $delta = 0, $edit = array()) { + if ($op == 'list') { + $blocks['comments'] = array( + 'info' => t('Comments'), + 'region' => 'content', + 'status' => 1, + ); + return $blocks; + } + else if ($op == 'view') { + $block = array(); + $node = menu_get_object(); + if (!empty($node)) { + $block['subject'] = t('Comments'); + $block['content'] = comment_display($node); + } + return $block; + } +} + +/** + * Helper function to render and return comments. + * + * @param $node + * A fully loaded node object. + */ +function comment_display($node) { + static $output; + + if (isset($output)) { + return $output; + } + $output = ''; + if (function_exists('comment_render') && $node->comment) { $arg2 = arg(2); - $vars['comments'] .= comment_render($vars['node'], ($arg2 && is_numeric($arg2) ? $arg2 : NULL)); + $output .= comment_render($node, ($arg2 && is_numeric($arg2) ? $arg2 : NULL)); } + return $output; }