1

Any clues or examples how to programmatically create node types with cck fields in Drupal 6? I would like to create a content type with has a cck file field in it. The Example module has an example of creating a node type but it does not utilize existing cck fields.

2 Answers 2

1

This blog post explains one way to do this: http://www.openbandlabs.com/blog/2009/06/programmatic-cck-content-type-creation

1
  • An answer should at least have the relevant part of the article it links to. Please try to make your answer a bit more complete.
    – berkes
    Commented Sep 1, 2011 at 16:14
0

You can use Features module.

This module allow to export not only a content type, but a lot of other configurations.

In your case just define your content type, and then go to Features admin pages, click the 'Create new feature' link, fill the form and select Content Type on the select widget and then tic your content type in the contetn types that is shown on the right. Then just click export. This gives you a zip file with a autogenerated module with your content type. Just install in your site as a normal module, go to the Features admin page (you need Features to enable it) and enable that module/feature.

Benefits of using this method is you can update your content type. Just edit your content type in tyour first site, generate your module again (click regenerate) and deploy in your second site. Then go to Features admin pages and you will see your module/feature mark as 'Overriden'. Just use the revert function to update (revert your content type to what is in the module code).

Features is a powerfull module, but use with caution: if you put many things inside a feature (content types, menu, permissions, etc) you may have some conflicts later (may be not, but is better to start using it with small features).

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.