I am writing a module that will create the data types for my site. I am using hook_node_info to create the type itself, then I am using field_create_field and field_create_instance to add fields. field_create_field and field_create_instance are functions, so I am wondering which hook they should go into. My two best guesses at this point are either hook_node_info or hook_install. The api seems to indicate hook_install, but I find this confusing. hook_install happens before hook_node_info, so how can you add fields to a content type that does not exist yet? Also hook_node_info happens every page load, but hook_install only happens once (at the time that the module is installed.) Am I creating my content type correctly or am I missing something?

  • The short version is: create two modules. One that defines the field, and one that consumes it.
    – Clive
    Commented May 19, 2014 at 15:48
  • What's the long version?
    – Hoytman
    Commented May 19, 2014 at 15:51
  • Code, code and more code :) (I'm not trying to be unhelpful by the way, when I get a chance later on I'll try to dig out the relevant links)
    – Clive
    Commented May 19, 2014 at 15:56
  • Thanks. There was another post that recommended using features. I attempted to use features in the past to do this, but the content types that were produced were un-usable (generated errors when an attempt was made to create content using them.)
    – Hoytman
    Commented May 19, 2014 at 16:14
  • 1
    I'm using features extensively with content types without problems.
    – sanzante
    Commented May 19, 2014 at 16:22

1 Answer 1


Instead of attempting to create your datatype module from scratch, use the Features module to store your content type settings in a feature generated module. This is faster, but may not cover all of the options that you need (field order, field groups or autotitle.)

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.