13

I want to clone a node type and add a few fields in it. I think the simplest will be to duplicate it and start working on it.

It seems there is no official way to clone a content type in Drupal 7. Features may allow it but there is no written procedure as to how it could be done.

I've even tried Bundle Copy module.

What'll be best way to clone any content type in Drupal 7?

12

The easiest way is to use the Bundle copy module, but if you can't get that to work I'd recommend the Configuration Management module.

The configuration management module enables the ability to keep track of specific configurations on a Drupal site, provides the ability to move these configurations between different environments (local, dev, qa, prod), and also move configurations between completely different sites (migrate configurations) without the use of modules with all configuration being owned by the site.

It's basically features with the stuff you don't need. Its sole purpose is to move configuration from one site to another.

  • How to use Bundle copy? I've exported Article type - now what do I do to change it's name before importing the same code? – AgA Jan 21 '13 at 12:10
  • Just run a string replace...replace 'old_content_type' with 'new_content_type', I've never had a problem using that method before – Clive Jan 21 '13 at 12:21
  • Thanks ... can I replace "article" for cloning Article content type? – AgA Jan 21 '13 at 12:51
  • Yes, but make sure your string replace is case sensitive and includes the apostrophes (it's not an exact science). So the PHP code would look like str_replace("'article'", "'new_type'", $export_code); – Clive Jan 21 '13 at 12:54
  • You mean only machine name needs to replaced? – AgA Jan 21 '13 at 13:40
4

I'm using the Field Tools Module for D7; it does exactly what you need.

  • Does this help to migrate multifields, unsure how to use this – pal4life Jul 24 '14 at 19:31
3

I've created Content Type Clone, available as a sandbox project here:

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

It allows you to clone a content type in one click without having to look at PHP code or perform complex manipulations.

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

Edit 1: 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.

Edit 2: The official release of Content Type Clone for Drupal 8 is available on the same page.

2

Feature module is best option yet.

Here's what you need to do:

  • Export the content type that you want to clone as a Feature.
  • Re-name the content type (i.e., change the "machine name") in your Drupal site
  • Upload and enable your Feature

This page may have your answer for "official way to clone a content type in Drupal 7".

  • 1
    Can't agree with that sorry. Bundle copy is much easier to use (and more lightweight) than features. Ditto Configuration – Clive Jan 21 '13 at 11:58
  • Can you please tell me which fields to change exactly in the exported module and link about this "official" information? – AgA Jan 21 '13 at 12:11
  • +1 @Clive - we've just used Bundle Copy here - it provides a menu option 'clone' under 'Structure' in the Drupal admin/config menus to clone the content type. Exactly what we hoped for when considering this module. It seems to work fine. – therobyouknow Oct 1 '14 at 10:25
  • @monymirza this 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. Use the dev version (at time of writing, currently 7.x-2.x-dev) of Bundle Copy (corrected my original comment made on Oct 1 '14 at 10:29 to mention functionality currently in dev version) as this provides a 'clone' menu option in 'structure' menu, out of the box, it was made for this task. – therobyouknow Feb 16 '15 at 15:54

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