Home ›
Delete a content type programmatically in Drupal 7Delete a content type programmatically in Drupal 7
Submitted by Benjamin Melançon on February 15, 2012 - 10:06pm
This is what i put as an update hook in a .install file:
<?php
/**
* Delete unused content types.
*
* Adapted from node_type_delete_confirm_submit().
*/
function anjaliup_update_7005() {
$types = array(
'simplenews',
);
foreach(
$types as $type) {
node_type_delete('simplenews');
variable_del('node_preview_' . $type);
}
node_types_rebuild();
menu_rebuild();
}
?>
Not tested yet.
Searched words:
drupal 7 programmatic delete content type
Comments
Thank you, these help me :)
Thank you, these help me :)
The easy way:
Manually go to /admin/structure/types/manage/"CONTENT_TYPE_NAME"/delete it will delete it
There is a mistake in the
There is a mistake in the code, I think.
node_type_delete('simplenews');
should be
node_type_delete($type);
Post new comment