I've implemented hook_node_info in a module, in order to define a custom node type.

In D5, this alone isn't enough to create custom node type. The table is created, but the node/add option doesn't show. Turns out you need to implement hook_form() too. (This is a lack in D5 documentation...)

On D6, node/add does appear for the new content type, but it's lacking a title and body, even though the API docs for the hook say that has_title and has_body default to TRUE.

Comments

gdevlugt’s picture

Actually I wonder if this is a bug at all. The way I see it is that through hook_node_info() your module provides information about the content type it's implementing. By setting 'has_title' or 'has_body' you're basically telling Drupal your content type has a title or body, not that form fields for these fields should be provided on the add/edit form. These you need to implement yourself in hook_form(), like before with Drupal 5.

However, I do think that the behaviour of Drupal 5 made more sense. Now, in Drupal 6, just providing a hook_node_type automatically adds an add/edit form in the menu, while possibly this is not something you want (for instance, if you add/edit nodes programmatically). In Drupal 5 you also had to implement hook_form() to get the add/edit forms which is logical since why otherwise implement hook_form() ?

joachim’s picture

It seems strange if you're used to inheritance -- having to copy and paste the code for creating title and body fields seems a waste of space and effort.
A shorthand way of including title & body would make a lot of sense, and the definition of hook_node_info sort of implies this.

sun’s picture

Status: Active » Postponed (maintainer needs more info)
joachim’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)