Add comments to custom node I have a module which shows content with the page callback. Here is my page callback (just the relevent code):

function my_page_callback() {
    $build=array();
    $build[] = array(
        '#theme' =&gt; 'my_theme',
        '#marker' =&gt; 'foo',
        '#data' =&gt; ...,
        '#contextual_links' =&gt; ...,
    );
    $comment=comment_node_page_additions(node_load(getTargetNodeId()));
    $build[]=$comment['comment_form'];
    return $build;
}


However the function getTargetNodeId() retuns a valid id of a node which is generated unter some conditions with this code:

$node = new StdClass();
$node-&gt;nid=42;
$node-&gt;vid=42;
$node-&gt;uid=1;
$node-&gt;type = 'my_type';
$node-&gt;status = 1;
$node-&gt;title = "Fresh generated";
$node-&gt;content['mapping'] = 4711; // some internal magic
$node-&gt;comment='2';
$node-&gt;language = LANGUAGE_NONE;
$node-&gt;body[$node-&gt;language][0]['value'] = "This text should nobody read.";
node_save($node);


Even if in the code above the nid and nid are fixed I take care of it the ids are unique.

And here is my code where I render my node:

function module_node_view_alter(&amp;$build) {
    if($build['#bundle']=='my_type') {
        $p=my_page_callback;
        $build['body']=$p[0];
    }
}




However the the comment header is generated but the input field is missing. What is the problem?
If my_type is a content type defined in the Drupal site, then I would check in admin/structure/types/manage/my_type/comment/fields that you didn't delete the comment body.



If this is what happened then the node page changes from what shown in the following first screenshot to what shown in the second screenshot.





The screenshots has been taken using the user #1 for my test site, which means what shown happens to every user.

The same thing should happen when the content type has been deleted, or it has never existed on the Drupal site.

There could be other reasons:


The only input format available in that site is not accessible from the user who is visiting the page your code is outputting. This is not clearly the case if you are using the user #1 to visit the page.
It also means the site doesn't have the default input format, which is not possible to disable from the user interface. It could be the default input format has been deleted from the database; if this is the case, users would have problems also editing nodes, as the input formats used for comments are the same used for nodes, even if a comment for a node using (for example) full HTML could use plain text, or filtered HTML.
The content type has been created programmatically, in a way that didn't cause hook_node_type_insert() to be invoked. If this is the case, then the Comment module doesn't have the possibility of adding the comment body field, which is done using the following function.

function comment_node_type_insert($info) {
  _comment_body_field_create($info);
}