I am creating a module in the ".install" file, using the following code:

// if not exists, create new content type
if (!node_get_types('type', 'houses')) {
  $info = array(
    'type' => 'houses',
    'name' => t('Houses'),
    'module' => 'node',
    'description' => t('Manager Houses'),
    'locked' => FALSE,
    'custom' => TRUE,
  $info = _node_type_set_defaults($info);

It creates a new content type, but how do I create additional fields (e.g. text, nodereference)?

2 Answers 2


Instead of creating the node type and fields by hand in code, you should use the features module which does the same thing, but has support for a bunch of other things as well, like reverting changes made to what is saved in code.


Have a look at programmatically created cck fields. Also see Creating a Compound Field Module for CCK in Drupal 6.x and Programmatically add CCK field to content type.

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.