I learned yesterday that the correct way to create a node type is by implementing hook_node_info
inside a .module file. Before I had been programatically creating node types in a .install file via node_type_save
, like this:
// Create node type
$type = array(
'type' => 'fruits',
'name' => st('Fruits'),
'base' => 'node_content',
'description' => 'Contains information about fruits.',
'custom' => 1,
'modified' => 1,
'locked' => 0,
);
$type = node_type_set_defaults($type);
node_type_save($type);
I had also been setting the node type options in the .install file, like this:
// Set 'fruit' options.
variable_set('node_preview_fruit', 0); // Set 'Preview before submitting' to 'Disabled'.
variable_set('node_options_fruit', array('status')); // Set 'Default options' to 'Published'.
variable_set('node_submitted_fruit', 0); // Unset 'Display author and date information'.
variable_set('comment_fruit', COMMENT_NODE_CLOSED); // Set 'Default comment setting for new content' to 'Closed'.
variable_set('menu_options_fruit', array('navigation')); // Set 'Available menus' to 'Navigation'.
variable_set('menu_parent_fruit', 'navigation:0'); // Set 'Default parent item' to '<Navigation>'.
Is this the correct way to programatically set node type options: like this, inside the .install file, even though the node type itself is created inside the .module file?