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(
        '#theme' => 'my_theme',
        '#marker' => 'foo',
        '#data' => ...,
        '#contextual_links' => ...,
    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->type = 'my_type';
$node->status = 1;
$node->title = "Fresh generated";
$node->content['mapping'] = 4711; // some internal magic
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = "This text should nobody read.";

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(&$build) {
    if($build['#bundle']=='my_type') {

drupal output

However the the comment header is generated but the input field is missing. What is the problem?

1 Answer 1


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) {

Not the answer you're looking for? Browse other questions tagged or ask your own question.