How to output comments anywhere within a theme

11 Feb · by Tim Kamanin · 1 min read

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

Required for comment verification



Suchi

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

Reply · 7 years, 10 months ago