How to output comments anywhere within a theme

A little snipped which is among very much needed and asked on Drupal.org forums: "How to output comments in desired place on the page and not on the bottom?". Here is the answer:


if (function_exists('comment_render') && $node->comment) {
echo comment_render($node, $node->cid);
$node->comment = NULL;
}

Put it into node.tpl.php or node-type.tpl.php However, you can output it in page.tpl.php too and actually, in any file, just make sure, you're able to path correct $node to the snippet.

19 Aug09:08

Hi I tried this approach and

By Suchi (not verified)

Hi
I tried this approach and it leads to an infinite loop. Basically, now when i post a comment, i get infinite comments on the node.
Any idea why that might be happening??

Post new comment

The content of this field is kept private and will not be shown publicly.