0

I have created a new node type within a module (for Drupal 7). I have created fields for it programatically as well and they all display. The one problem I am experiencing is that the title field does not display. I am not sure how or where to look to fix this. The title field does display in the node type's manage fields display.

Here is the code for creating the node type in hook_install():

// define the node type
  $type = array(
    'type' => $machine_name,
    'name' => $t($parameters['name']),
    'base' => 'room_reservations',
    'module' => 'room_reservations',
    'description' => $t($parameters['description']),
    'has_title' => TRUE,
    'title_label' => $t($parameters['title_label']),
    'custom' => FALSE,
    'locked' => TRUE,
    'disabled' => FALSE,
  );

// set other node defaults not declared above
  $content_type = node_type_set_defaults($type);

// add the body field
  node_add_body_field($content_type, $t($parameters['body_label']));

// save the content type
  node_type_save($content_type);
2
  • You have dollar signs before t functions. Have you assigned a function name to variable t? As in $t = get_t(); Also have you done some theming work or are you using one of Drupal's core themes? Commented Oct 9, 2013 at 0:10
  • Yes I did use $t=get_t(). I am not doing any theming with this (yet), just using Drupal's Bartik theme.
    – user5013
    Commented Oct 9, 2013 at 0:39

2 Answers 2

0

Drupal does not display the title field in the manage display page by default.

You would have to use Display Suite Module and enable a layout for the page to get the title and other fields to display in the Manage Display page.

4
  • The question refers to the manage fields page, not the manage display page.
    – rooby
    Commented Oct 9, 2013 at 12:26
  • I guess that needs clarification "manage fields display." I thought this meant the display page. Commented Oct 9, 2013 at 13:08
  • Yeah I guess it could go either way.
    – rooby
    Commented Oct 9, 2013 at 13:12
  • I meant the page where you add or remove fields. It does display on that page but when I go and create a new page based on that content type the title textfield does not appear. Sorry about the confusion.
    – user5013
    Commented Oct 9, 2013 at 15:32
0

To automatically have the node title you need to define "node_content" as base for the node type. Else I think you have to implement the title form field display/store for your node add/edit form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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