Drupal – Render Node Comment Form

Node Comment allows you to create the content type as comment. Instead of having only comment title and body, Node Comment lets you add CCK fields to comment content type.

Normally, if we want to render the default node comment form, you can use the drupal_get_form() function.

<?php
  print drupal_get_form('comment_form', array('nid' => arg(1))); 
?>

 

But this does not work for Node Comment even if you provide the valid form id. Try the following code instead.

<?php
if (function_exists('nodecomment_render') && $node->node_comment) {
  $node->node_comment = NULL;
  print nodecomment_render($node, $node->cid);
}
?>

 

Done =)

Reference: Render nodecomments form in node.tpl

2 thoughts on “Drupal – Render Node Comment Form”

    1. i think i made a mistake on the code. please try the following.

      <?php
      if (function_exists('nodecomment_render') && $node->node_comment) {
        $node->node_comment = NULL;
        print nodecomment_render($node, $node->cid);
      }
      ?>
      

      does it solve the problem?

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.