By laghalt on
I am writing a module that will produce three new content types. The documentation of the API is confusing - I have read the node_example.module http://api.drupal.org/api/file/developer/examples/node_example.module/5/... and finaly understood that its wrong. It says that you should name the hooks by the name of the node type - thats not true - the hooks is named by the module. Perhaps a example module should not have the same name as the example node?
My problem is still how I implement different hooks for different nodetypes, for example hook_insert or hook_access.
Comments
You can implement multiple
You can implement multiple node types in one module by specifying a different hook prefix in the "module" field returned from hook_node_info. Yes, it's a bit confusing, but your node type related hooks don't have to start with the module name.
From the hook_node_info() docs:
So if your module was called foo, and created two types, "car" and "rocket", you could define your callbacks something like this...
Your callbacks would then be something like...
function foo_car_insert() {}
and
function foo_rocket_insert() {}
http://www.trailheadinteractive.com
Ok, now Im confused - I read
Ok,
now Im confused - I read that the hooks related to modules. Thank you for the answer.
I have already figured out the foo_node_info array - that was no problem - it was in the api doc.
But witch hooks belongs to the type and witch belongs to the module - does the hooks in node_example.module belong to the nodetype?
Are all these not related to the module: hook_access, hook_delete, hook_foorm, hook_insert, hook_nodeapi, hook_perm, hook_update, hook_validate, hook_view ?
Where can I find documentation on this?