Issue
Uninstalling a feature which creates a content type hides the "Delete" link on the admin/structure/types
.
Uninstalling a feature which creates a content type hides the "Delete" link on the admin/structure/types
.
Using a hook_uninstall()
in FEATURE_NAME.install file and changing the status of the content type, so the system thinks it is an unlocked, custom content type.
<?php
/**
* Implements hook_uninstall().
*/
function FEATURE_NAME_uninstall() {
// List custom content types added by this feature
$custom_ctypes = array(
'blog',
);
// Go through each and unlock the content type
foreach ($custom_ctypes as $ctype) {
db_query("UPDATE {node_type} SET `custom` = 1, locked = 0 WHERE type = :ctype", array(':ctype' => $ctype));
}
// Clean Drupal cache; this is necessary for the "Delete" link to appear
// next to the content type created by the feature.
drupal_flush_all_caches();
}
This will make the "Delete" button appear for that content type, so you can delete it from the admin.
Hope this helps someone!
node_type_delete($ctype);
after the query in the for loop.
Commented
Feb 1, 2013 at 19:05
mysql> UPDATE node_type SET custom = 1, locked = 0 WHERE type = '<content type machine name>';
Commented
Feb 18, 2014 at 20:00
For me, the solution was to load the delete page manually since there is no "delete" link on the content types page. To do this, you just need to construct the URL yourself by following the same URL structure as the delete page for other content types:
admin/structure/types/manage/YOUR_CONTENT_TYPE_MACHINE_NAME/delete
This brought up the content type delete confirmation page, which then allowed me to delete the content type.
For reference, see this thread on Drupal.org:
https://drupal.org/node/1055460#comment-7297680
Regards,
@cmsdave
.info
file and remove the content type, then it would actually delete.
Commented
Oct 21, 2014 at 10:47
The above method does not delete taxonomies, but this can be achieved by appending the following after disabling and uninstalling the module:
// Delete taxonomies.
$machine_names = array('taxonomy_a', 'taxonomy_b');
foreach ($machine_names as $machine_name) {
$taxonomy = taxonomy_vocabulary_machine_name_load($machine_name);
taxonomy_vocabulary_delete($taxonomy->vid);
}
Another solution that worked for me directly to the database in my development site. Remember to always backup your database.
To manually delete a content type that was created by a feature #16 what Nedjo suggests is the following:
- Disable the feature. I've sometimes run into problems with this--a feature won't disable. In this case, remove the feature module code.
- Determine the machine name of the content type to be deleted, e.g., 'mytype'.
- In the database, revert the node_type table values to the defaults as if the content type were created manually through the UI:
mysql> UPDATE node_type SET module = 'node', custom = 1, modified = 1, locked = 0 WHERE type = 'mytype';
- Clear caches to ensure the content type change is available.
- Through the UI at admin/structure/types, delete the content type.
If you use admin_menu module, you will still see the delete links in pull-down menu Structure / Content types / [content type name] / Delete, even if they are not displayed on the content types page.
I would say it's pretty safe to use this delete link if you assure there are no other references to this content type anymore.