2

Imagine we have 50 different professions in the same domain (medicine for example). In a region, we can have 5 doctors who have the same addresses, and in another region we can have 15 doctors in different addresses. We want their information to be stored in the database (e.g. addresses, telephone number).

So I decided to do this:

  • Content type 1 (general information): title, field_region, field_tel, field_email, etc.

  • Content type 2 (specific information): title, field_region, field_inherit_from, field_tel, field_email, etc.

Thus, when we want to add specific information to a profession X from region Y, we have to create a new content of content type 1 and then create content type 2 which will override specific fields from content type 1.

Keep in mind that a same region may have 10 professions who have same phone number, same email address but 7 professions have its own email address for instance. Also, keep in mind that there is more than 15 different fields (so 10 different type of information about the professions).

How can I do this? I just don't know what the best way to do it is.

1

As you say Content Type 2 has the same fields of Content Type 1 (except for the reference) I think you don't need 2 content types in your model.

You can have a region with 10 professions with similar information, but they need something different between each other. They can have many similar fields (infos), but they need a field with a different value. If not, why do you need 10 nodes (professions) with the same information?

And you can have other 7 professions who have different information than the first 10 professions, but they are all Profession. All the 17 professions have the same fields with more differences others with less.

In this case, you can use only one Content Type and create in first place the most general professions nodes (with the most general fields) and use a module like Node clone.

The clone module allows users to make a copy of an existing item of site content (a node) and then edit that copy. The authorship is set to the current user, the menu and url aliases are reset, and the words "Clone of" are inserted into the title to remind you that you are not editing the original content.

  • Thank you Adrian Cid Almaguer. In fact, I complicated my life. Your proposition sounds efficient and cheap. Thank you again :) – Wilord Jul 26 '16 at 8:15
  • @Wilord a pleasure help you, good luck with your projects ;-) – Adrian Cid Almaguer Jul 26 '16 at 13:06
1

I am not sure if you are using D7 or D8, so will take a high level approach.

I would suggest that you will need to use an entity reference field on Content Type 2 (Person) to reference the item of Content Type 1 (Profession template) that will provide the default values for fields that are not filled in. They might even be the same content type if all the fields are the same, and all can accept default values (though if so watch out for recursion in the next step).

Now using a custom module, on node load, you can check for empty fields and replace their values with those of the referenced node.

  • Thank you autopoeitic, your proposition is great. I will go for the solution proposed by Adrian, but I will keep in mind what you adviced me :) – Wilord Jul 26 '16 at 8:19
  • No problem. Bear in mind that Adrian's solution, which is probably a more efficient way of dealing with your core problem, does not allow in itself, a way of changing the 'inherited' fields across multiple nodes, but you could use VBO for that – autopoietic Jul 26 '16 at 8:23
  • The question got updated after this answer was written. Maybe you want to review the "high level approach" also then? – Pierre.Vriens Aug 25 '16 at 10:50

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.