2

In drupal 6 I have a content type with a lot of fields, voting, referenced nodes (as answers), etc. Now I would like to create a very similar content type - same behaviour and everything, there are only 2-3 fields that are different, but everything else is the same. Now comes the question: Should I create a separate content type, setup everything, use separate voting, etc? Or is there a way to somehow 'inherit' everything and change only 2-3 fields that need to be changed?

1 Answer 1

1

If you are going to do this often, or expect changes that require these two types to be in sync in the future, you might investigate the http://drupal.org/project/features module, which packages stuff up like this. But, if it's a one off thing, I'd just go and create a new content type and reuse the existing fields plus the new/different ones in the second content type. If you don't want to type everything in again, you should be able to use the CCK export feature and then just change the name and type of the result and import it, which if all goes well, will create the second type for you identically to the first. Then just add the new/different fields manually.

5
  • 1
    SO it means that if I have a ontent type trousers - with fields size, colour, brand, some voting and images and I would like to add additionaltypes - such as shirts, shoes, skirts and so on, which differ slightly from each other I would have to create a content type for each of these? I think there is a potential for improvement here for Drupal...
    – Vonder
    Apr 25, 2012 at 22:48
  • I'd like to know the answer to this to. Say I have twenty-five content types and they share enough fields to make the "field inheritance" concept that Vafello is talking about make sense. Do I have to make 25 separate content types? Is the answer the same for Drupal 6 and 7? What about Drupal 8?
    – Jim
    Apr 25, 2012 at 22:53
  • 1
    To Vafellos comment, that, or your create a content type called "item" with all the fields you could possibly need, and just hide the ones from the various edit/add/view pages and forms based upon a field or other criteria. Off the cuff, for example, if you had a field in it called type, that could be a dropdown for shirt/shoe/skirt etc and then based upon this, fields could be displayed that are valid for whatever is chosen. To Jim, I don't know enough about D7 yet to comment on that, let alone D8, but you don't HAVE to do anything, there are many solutions to almost every Drupal issue.
    – Jimajamma
    Apr 25, 2012 at 22:53
  • For Drupal 7 there is something - drupal.org/project/bundle_inherit
    – Vonder
    Apr 25, 2012 at 22:56
  • Also see drupal.stackexchange.com/questions/27741/…
    – Jim
    Apr 25, 2012 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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