A couple of interesting finds whilst creating my own node type with a module.
Having built the node type through a module, I then spent hours trying to find out how to control the node form settings like comments and promote to front page. I even spent some time on the IRC but nobody knew the answer.
Sometime going through the API documentation is like digging through liqueified mud.
However the first way I found was to add this to hook_install
variable_del(‘comment_node_example’);
but reading on lots of people are saying that it’s bad to do it that way because of caching – If anyone can expand on that I would be grateful.
The second method and the one I went with was
function node_example_node_prepare(&$node) {
if($node->type == ‘node_example’) {
$node->promote = 0;
$node->comment = 0;
}
}
I hope this helps anyone someone else.
A bug – issue exists in drupal 7 in that you get lots of comment errors when you uninstall a module that has a content type.
Notice: Trying to get property of non-object in comment_node_type_delete()
You need to set the base – ‘node_content’
// Define the node type.
$node_example = array(
‘type’ => ‘node_example’,
‘name’ => $t(‘Example Node’),
‘base’ => ‘node_content’,
‘description’ => $t(‘This is an example node type with a few fields.’),
‘body_label’ => $t(‘Example Description’),
‘promote’ =>0,
);