19

How to copy content type in Drupal 7 ?

I can't find a button to duplicate content type.

13

If you mean export by duplicate use the Features module.

The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.

Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.

  • 1
    This seems to be the best method at the moment. Unfortunately there is no module (yet?) like Content Copy in Drupal 6. – marcvangend Sep 20 '11 at 12:10
  • I need to export then import you mean? – Raptor Sep 21 '11 at 2:18
  • 2
    Features is overkill for copying a content type. It is intended to bundle various entities/modules/other together for highly customized purposes. If you want a simple copy of a content type see @user3936 below. – doub1ejack May 29 '13 at 17:30
  • I found the Bundles Inherit module to be easiest; see my answer below. – Matt Browne Jun 6 '13 at 19:11
19

Maybe too late you can use the Bundle Copy module:

Bundle copy is a replacement for the Content copy module which lives in the CCK project for Drupal 6. Has export/import support for: Node types, Taxonomy, User, Field API fields, Field groups

UPDATE 7.x-2.x-dev notes

The following features have been added:

  • Export/import of Field Collection
  • Cloning of Content types
  • Export/Import of Commerce Entity bundles

Drupal 8: Bundle Copy is in Drupal 8 Core CMI.

  • 1
    Bundle Copy is not suitable for cloning a content type to another content type on same site. And, doing a search/replace is not straight forward. There are node arrays that reference other content types. I haven't quite figured it out, but have asked feverishly. If I knew what was safe and not safe to change it would be helpful. Just a warning. (One user responding to this same request noted that he had db corruption errors when doing search/replace of all instances of original content type machine name. – user7558 May 23 '12 at 0:10
  • @user7558 Bundle Copy is not suitable for cloning a content type to another content type on same site. Yes it is, you just need the smallest bit of manual intervention – Clive Jan 21 '13 at 13:06
  • Their is an issue for "Cloning content types on same site?" drupal.org/node/1589118 – gagarine Jan 22 '13 at 9:22
  • 1
    The 7.x-2.x-dev supports cloning a content type on the same site via the UI. – mpdonadio Jul 24 '13 at 19:27
  • I think Bundle Copy is the favourite option as using Features approach would involve editing machine generated code by hand to search/replace/rename the feature-generated content type code. Unless one knows the Feature module code well as to how it generates this code, there may be unknowns/assumptions made about hand coding this way and unlucky outcomes. Updated Oct 1 '14 comment 1 of 2 – therobyouknow Feb 16 '15 at 15:59
14

I used the Field tools module, and it worked flawlessly.

All I did was create my second content type, used this module functionality to clone all the fields to the new content type, then uninstalled the module. Bundle copy and Features seem like ridiculous ways to duplicate a content type, this was super simple and exactly what I wanted.

  • If all you want to do is duplicate a complex custom content type this is the way to go. Features has a lot of unnecessary overhead and your content type is tied to a generated module. Bleh. Use this. Install/enable, go to the content type you want to clone, look for a Clone Fields tab up top, select the fields to copy, the node to copy them to, and you're done. – doub1ejack May 29 '13 at 17:26
  • 1
    I think Field Tools is the fastest and simplest way. Thank you! – Roger May 7 '14 at 11:04
  • Create a new, empty content type, Tools tab, Clone fields to this bundle, select fields from an existing node content type, Add field instances. – Hugo Feb 3 '15 at 9:32
4

I found the (relatively new) Bundle Inherit module to be a very easy way of doing this. Be sure to enable the "Bundle Inheritance Node" (bundle_inherit_node) module in addition to the bundle_inherit module, then you'll get a new "Inheritance" tab when creating new content types.

(It also gives you a choice between "soft inherit" and "strict inherit"...as far as I can gather, "soft inherit" simply does a one-time copy of the fields whereas "strict inherit" keeps track of the inheritance hierarchy.)

4

The easiest way is to use Bundle Copy - the 7.2 version which is in development but worked perfectly for me.

After installing the module, go to your "content types" page and click on the new "clone" tab.

Under "Source Bundle", select the content type you want to clone.

In "New Bundle Name", enter the name of the new content type you want to create. Click on "clone" and you'll now see that new content type in your list.

Field Tools also does the job but it's not as straight forward.

1

Just for the history, there is one more module that can handle this.

Config in Code (CINC)

1

Otherwise, Content Type Clone allows you to do it quickly and simply, without having to look at PHP code or perform complex manipulations:

https://www.drupal.org/sandbox/davidfiaty/2745827

It's a sandbox project at the moment, but it will soon be available as an official Drupal module.

Edit: The official release of Content Type Clone for Drupal 7 is here! https://www.drupal.org/project/content_type_clone Drupal 8 version coming soon.

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.