Adding a new content type programmatically in .install file or .module file? There are 2 different ways to create a new content type programmatically.


First one, which I also use, is to create it in your custom module's .install file in hook_install() using node_type_save() and attaching the fields also in hook_install() with field_create_field() and field_create_instance() .
The second one, which in Node Example module is used, is to create it in your custom module's .module file using hook_node_info() and creating and attaching the field instances in hook_node_type_insert()


I am preferring the first method, since my feelings say that is better to maintain (i.e. adding/updating new fields via hook_update_N()) and it suits better in .install file. But, I keep myself asking why it is done other way in Node Example module.

Does anyone know the CONs and PROs of using both methods to create a new content type in code?
Some hooks, like hook_delete are only called on the module that defines the node's content type. If you save content type to a database using node_type_save(), it might not be recognized as "defined by module" - it acts as content types created by user. Unless, of course, you will set $info['module'] to point at your module - in that case created entries should work the same way.