Update: You may also want to check out the Bundle Copy module. I haven’t tried it yet, so let me know in the comments if it works!
Recently, I read the Stanford Tech Commons article on Cloning a Content Type in D7 at https://techcommons.stanford.edu/topics/drupal-7x/cloning-content-type-d7. It proposes a simple but (mostly) effective way to wind up with cloned content types in Drupal 7. Summarized:
- Create a content type and set it up as desired.
- Export the content type and its field to a feature module with the Features module. *** WARNING: DO NOT ENABLE THE FEATURE MODULE YET. ***
- The existing content type will be the clone, so edit it and change the machine name; this renames it and changes the type of all existing content to the new name.
- Enable the feature module. Your previous content type is restored (potentially after reverting).
I found that things didn’t quite go as advertised with this approach. I couldn’t get the existing content type to be recreated when reverting the feature. I found a workaround; it entailed editing database tables in phpMyAdmin, so it’s not ideal; however, it does appear to be safe as it is only old data that is deleted. This should be done only if you have enabled the feature module and you cannot revert it, meaning that shows Overridden despite your best efforts.
- Open phpMyAdmin or your database tool.
- Browse to the field_config_instance table.
- Sort by the bundle column and delete all rows corresponding to the content type encapsulated in your feature (not the already-renamed one).
- Now browse to the node_type table.
- Edit the row corresponding to the renamed content type, and you should see that its orig_type column still contains, predictably, the original name. Unless you’re sure you need this information, in which case you probably won’t be able to revert the feature module, edit this row and change the value of this column to the same as the type column. In other words, if the new machine-readable name for your content type is income, as it was mine, change the value of this column to income as well.
Try reverting your feature again. The content type will revert successfully, and the fields will remain Overridden. But don’t despair! They will be properly configured when you go and have a look. It’s just that Drupal adds some additional information that for one reason or another will not have been exported to the original feature, or wasn’t in my case. Recreate the feature module and re-export it to make it show Default again.
I hope these third-party errata help someone out.