How do I start to develop a Drupal 7 module that adds a new content type with some custom fields, so it generates all the output I want?


Although its possible to do programatically, your easiest bet would be to use features.

This is how you would do it:

  1. Manually create your content type
  2. Manually add fields
  3. Create a new feature and export the content type (and its fields)
  4. Done!

Now if you install this feature is a fresh Drupal installation that content type and fields will be automatically added.

  • Well I need to develop this as a normal module. So can I later add more code in the files and "upgrade" this module and it works like a totally normal module? Is it better to rely on features or is it better to write a module from scratch that makes all this and creates the content ype, adds the fields ... and later does some database querys, file conversion ...?
    Oct 12 '11 at 19:36
  • You can always update your content type, re-create the feature and existing installations will be updated. And if you want to add something special, you can always implement a second module which does that using the various hook_node_* hooks.
    – Berdir
    Oct 12 '11 at 19:54
  • Well I will give it a try.
    Oct 12 '11 at 19:57
  • You can just add your code to the .module file created by features, for Drupal this is just a regular module.
    – Attiks
    Oct 12 '11 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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