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.

Comments

Submitted by Suchi on Thu, 08/19/2010 - 10:08

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??

Add new comment

You are here