By nadongtae on
Hi every body, i know how to make a module with a node . However, how can i make a module with many nodes ? For example, i want to make a module company with 7 nodes (buy,sell,news,fake news,..). All nodes will be presented in the same page like tabs. How can i do that ? Thanks for your supporting.
Comments
See api.drupal.org and read
See api.drupal.org and read up on hook_node_info.
Suuch Solutions supports The GhanaThink Foundation
I read that but..
I read that but the information is so general. Soory,but can you give an simple example that 1 module can have 1 more node. Thank you very much !!!
re: more than 1 new node type defined in a module
Here is an example:
And so each hook related to a node needs to have its logic split in the same way.
Dave
re: Another possibility
Check this out at well:
http://drupal.org/node/46298#comment-86845
re: more than 1 new node type defined in a module
Thanks for the above info. Is this the only way to achieve multiple node types in a single module?
I currently have a module written for drupal 4.6. This uses separate hooks for each node type, so the view code is like this:
I know that logic for hook_node_types() and hook_view() has changed since 4.6 (and I have updated my module accordingly), but can you still use separate hooks for each node type? I can't find anything in the documentation that tells me that this has changed since 4.6. My module defines 4 different node types, so some hooks such as hook_form() could end up being very complex. Also, I have each node type defined in separate include files to make them easier to maintain. If I must combine the hooks, I can no longer use the include files.
Your help is greatly appreciated.
How hooks are called
My impression is that if you look at the function 'module_invoke_all' what you'll see that it has a foreach loop in it, and that it calls the name of each module using 'module_implements' which apparently creates an array of every module that is using a particular hook, and calls each hook.
If we look at 'module_implements' we can see that is starts a list of all of the modules, and uses 'module_hook', presumably to check to see if a particular hook is implemented in the particular module, and if we check that last function, we can see that is actually what it checks.
So this means that unless 'apple' is in the list of modules in your directory, 'apple_form' won't be called.
This means that the way you currently have it set up shouldn't work.
Dave
Re: How hooks are called
Thanks for that info Dave. I'll have to update my code.
Maybe it was just luck it ever worked in the first place! :)
Ian
Fantasy Formula 1