4

I have a content type named "event_xyz" that I want to rename to "event". I figure I can clone the content type and then delete the original. But I don't see any tuts or modules on how to do this.

Alternatively, is there a way to rename a bundle's machine name?

I found a closed question related to cloning content types for Drupal 7, but not for Drupal 8.

  • 1
    have you try to export the entity config and change the id and name inside this config for this content type ? – Kevin Jun 21 '17 at 15:41
  • Let me try that. – oknate Jun 21 '17 at 15:43
  • but you ll have some work, you need to export field, field storage change mapping... – Kevin Jun 21 '17 at 15:50
  • 1
    It seems to have worked, see my answer. – oknate Jun 21 '17 at 15:58
4

Here's one solution to rename a content type using Kevin's suggestion.

1) search and replace in the codebase for "event_xyz"

2) go to /config/sync directory (or where your configs are)

3) run command to search and replace in filenames

4) delete content type "event_xyz"

5) run config import ("drush cim -y")

This worked and took less than ten minutes, although I didn't have to delete any content.

4

The best way to do this is the entity_clone contrib module. I downloaded it, installed it, hit the clone button and all of fields and form settings were copied to the new content type. It worked very well.

0

You can use Content Type Clone designed specifically for this task. It's available for Drupal 7 and Drupal 8: https://www.drupal.org/project/content_type_clone

-1

For D7, you can use Node Convert. Build a fresh content type, with fields new/same/similar then use field mapping (field matching) to move/migrate them. Maybe or maybe not with Views Bulk Operations.

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.