4

I was trying to use a project feature from openAid features based distribution. So I copied all the features from that distribution and required contrib and custom modules in my drupal installation.

Then I enable the project feature from admin/structure/features which enables few other features like resources and partners.

Any how I was unable to make it work as per my requirement so I deleted all three folders including the features, contrib and custom modules.

but the issue is that it has created three content types Project, Partners and there is no option to delete them.

Please let me know if there is a way to delete those content types which were created through the features which I have already deleted.

5 Answers 5

2

You may try the following code for getting the delete link (as we get delete link for the manually created content types) for the content types as created by the feature module:

<?php
/**
 * Implements hook_uninstall().
 */
function FEATURE_NAME_uninstall() {

  // List custom content types added by this feature.
  $custom_ctypes = array(
    'CONTENT_TYPE1',
    'CONTENT_TYPE2',
  );

  // Loop 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();
}
?>

After executing the above script, you will get the "delete" link as we get for the manually created content type and than you can delete the content type (created by feature module) from UI itself.


Another easy way to delete the content type: manually go to /admin/structure/types/manage/"CONTENT_TYPE_NAME"/delete it will delete it

Reference: https://drupal.org/node/1055460

3
  • Where should we put this code ?? in template.php or we need to create FEATURE_NAME.install file if we create this file do we need to put that in feature module folder ?? sorry for my lack of knowledge. Commented Oct 8, 2013 at 15:42
  • 1
    By the way Comment number 65 worked for me drupal.org/node/1055460#comment-5135094 Commented Oct 8, 2013 at 15:42
  • @Fahad Yeah that was an easy way, therefore I shared the link for reference. Hope your problem is resolved. Commented Oct 8, 2013 at 15:47
7

Open the content type (for example: article) for editing which should bring you to a URL:

admin/structure/types/manage/article

You can then append "/delete" into the URL like so:

admin/structure/types/manage/article/delete

Which should open a form that will let you delete the content type. I don't know if this lets you delete ones that are coming from an active features package, but it definitely does help you delete obsolete content types from inactive features packages. So be careful


FYI, if you do this for multiple content types, don't open all the delete forms in multiple tabs and try to be clever by deleting several types at once. Bad things will happen :-p Make a backup and delete one content type at a time.

1
  • 2
    FYI, if you do this for multiple content types, don't open all the delete forms in multiple tabs and try to be clever by deleting several types at once. Bad things will happen :-p Make a backup and delete one content type at a time. No, don't ask me how I know this…
    – thirdender
    Commented Oct 1, 2014 at 12:19
0

If you have devel installed, navigate to /devel/php and then node_type_delete($type) where $type is the machine name for the content type.

you have to execute the function no matter where,so devel is not required but yes will be a step less to have it.

0

Instead of trying to do it by custom, you could again install the feature module again and then trough the terminal first disable the module using

drush dis module-name

and then uninstall the module using

drush pm-uninstall module-name

This would help you to delete all the entries that the feature module created in your database.

1
  • If you don't have access to a terminal/drush then it can be done from admin/modules/uninstall
    – Beebee
    Commented Oct 8, 2013 at 15:55
0

The easiest thing to do (I think) is to use the admin_menu module (https://www.drupal.org/project/admin_menu). I already use this on most of my sites so it isn't an extra step for me.

With admin_menu enabled, you can simply hover over structure > content types > any type and the delete link will appear.

I just tested this out by moving a content type and a view from one site to another via features. Disabled the feature but the content type was still there with no delete link. Used the admin menu to delete the content type. Worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.