1

I know I can delete all nodes of a content type, keeping the content type, through bulk operations or such. If I'm not interested in keeping the content type, can I just delete the content type itself and all nodes will be gone with it?

This is the message I see when hitting the delete link for a content type, on Drupal 7.58.

screenshot

Translated from French, that is:

[Content type name] is used by 3 pieces of content on your site. It could be impossible to display them or to modify them correctly if you delete the content type.

The displayed message does not lead me to think outright that the nodes will be deleted, just that I might not be able view or edit them.

1
  • you need to delete first all those nodes, if you dont, you are not allowed to delete conten type
    – pinueve
    Jul 5 at 19:32

1 Answer 1

3

The confirmation message that Drupal 7.58 shows in English is the following one, where %type is the content type name and @count the number of nodes.

%type is used by @count pieces of content on your site. If you remove %type, you will not be able to edit the %type content and it may not display correctly.

Drupal 7.58 shows that warning, but it lets you delete the content type. What that warning says it's correct: Once the content type used by existing nodes is deleted, those nodes cannot be anymore deleted; they also won't display correctly, since the function that deletes a content type (node_type_delete()) deletes also the fields added to those nodes (with field_attach_delete_bundle()).

In Drupal 7.90, the latest Drupal 7 release available now, if you try to delete a content type for which there are nodes, Drupal won't allow you to delete it. It will tell you you need to first delete all the nodes of that content type.

For example, if I try to delete the Basic Page content type after I created a Basic Page node, instead of the confirmation form, Drupal will show me the following message (although the page title will be Are you sure you want to delete the content type Basic page?).

Basic page is used by 1 piece of content on your site. You cannot remove this content type until you have removed all of the Basic page content.

screenshot

Although Drupal 7.58 allows you to delete a content type for which there are nodes, it's preferable to first delete the existing nodes of the content type that is going to be deleted, following these steps.

  • On admin/content, select the content type you want to delete in type

  • Click on Filter

  • The list at the bottom of the page will show only the nodes of that content type

    screenshot

  • Click on the checkbox shown on the right of Title, in the header

  • Select Delete selected content from Update options (from the list that shows Publish selected content)

  • Click on the Update button

    screenshot

As side note, Drupal 7.58 isn't anymore secure. The following security issues has been fixed, in releases created after Drupal 7.58. (These are the last five fixed security issues.)

2
  • Thank you for the detailed explanation. Very strange. The message I get when deleting a content type is (I am translating from French site translation): "<Content type name> is used by <N> contents on your site. It could be impossible to display them or to modify them correctly if you delete the content type". As you can see, the displayed message does not lead me to think outright that the nodes will be deleted, just that I might not be able view or edit them. After checking, Drupal does allow me to delete the content type without deleting the nodes first. I am on Drupal 7.58 at the moment.
    – leducvin
    Jul 6 at 11:33
  • The screenshots I shown are for Drupal 7.90. I will verify which difference there are between Drupal 7.58 and Drupal 7.90 and update my answer accordingly.
    – apaderno
    Jul 6 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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