In Drupal 7, I have programmatically created a new content type with 2 new fields. Going to fill in the new content type, it displays a "Body" field that I do not want filled. Is there a way to programmatically install the new content type to hide the body field. I know I can use CSS to hide the body field, but, I think that is probably a kludge. I would like to use the correct programmatic method to hide the Body field.
You can do that using field_delete_instance()
Let us know if you need further assistance.
Content types do not have the body field by default - it is usually added when creating the content type:
// add content types
$ctypes = _my_module_get_content_types(); // get content types
foreach($ctypes as $ctype => $data){
if (!in_array($ctype, node_type_get_names())) { // check for collisions
$data = node_type_set_defaults($data); // default *does not* add body field
node_type_save($data);
node_add_body_field($data); // add body here (typical usage)
}
}
look around for the node_add_body_field()
fn and remove it if present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With