Home > 7 > How to create data types via module

How to create data types via module

May 19Hits:1

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?


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.)

Related Articles

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.904 s.