By joachim on
I'm trying to create a module that adds a new content type.
I've defined my hook_node_info, and got a message from Drupal saying the table's been created.
But the content type isn't showing up under Create Content.
The example at http://api.drupal.org/api/file/developer/examples/node_example.module/5 implements a lot of hooks, but this example does more than I want, because it adds extra fields.
Do I really need to implement all those hooks listed on that page just to do the basics? Eg, what's the point of implementing node_example_insert if all it's going to do is the standard node insert?
What's the minimum set of hooks that must be implemented for it to work?
Comments
hook_node_info ()
Should be sufficient to have your content-type recognized. Look here http://api.drupal.org/api/function/node_example_node_info/5
I don't think it is, unless
I don't think it is, unless I'm doing something wrong.
I've even tried the hook from node_example on its own in a module:
The database table is created, but it doesn't show in the Create Content list.
Line 2209 of
Line 2209 of node.module:
So an implementation of hook_form() is required -- even if it just is a copy of the same thing for page and story.
Does anyone know if this is still the case in D6? It seems a bit redundant.
I used the node_example
I used the node_example module to define my own content type. If I use admin console to create a new node everything appears to be working. If I want to create the node inside the code, I run into all sorts of troubles.
I tried to use drupal_execute('myrec_form', $values, $node); I got the sample from drupal_execute() api page:
The sample works fine for 'story' type. However, example_node won't work. A lot of things were missing when I tried to call drupal_execute().
Does someone have some snippet on creating a node for example_node as defined in http://api.drupal.org/api/file/developer/examples/node_example.module/5/... ?
I got it to work without
I got it to work without really understanding it. Call it crazy, here is the catch in case your scratching your head for the same problem.
The really crazy part is that I do have a form defined as 'myrec_form()', and I DO NOT have a form defined as 'myrec_node_form(), and that will make it work!!!
However, before you got carried too far away, you can't just put garbage string as your form name. It appears that you need to insert a '_node' in the middle of your form name.
I hope there is some documentation explains this kind of stuff. Well, for now, I need to move on...