1

How can I relate content in Drupal 7?

I have three content types:

  • Product Group ( With detail page )
  • Product ( With detail page )
  • Application ( With detail page )

A product belongs to a product group.

An application belongs to a product group.

How can I do this kind of relationship?

  • Hello and welcome. Please remember that opinion-based questions are not allowed here. "Best way" leads to arguments, anger, flame wars etc. We don't want that here. Please tell us what have you tried, and what exactly you wanted but didn't get. Precise "How to" questions are welcome. – Mołot Oct 29 '14 at 14:07
  • Please avoid to double post your question on Stackoverflow and Drupal Answer. stackoverflow.com/questions/26632396/… – Djouuuuh Oct 29 '14 at 14:42
3

The best way is to use the Entity Reference Module.

  1. Install the module
  2. At the Product add a field My Product Group and Field Type: Entity Reference. If you have many Products use the autocomplete widget.
  3. On the next page chose Target type: Node and then the as Target bundles the Product Group.

Now when you add a ‘Product’ you can assign the parent ‘Product Group’.

Do the same for Application and Product.

The final structure will be:

- Product Group
- (have) Product
-- (have) Application

To display the results is another story. You can go to ‘Manage display’ of the content type and Render the entity. Or you can use views if you like something more complex.

1

You can use https://www.drupal.org/project/entityreference. This module allows you to reference all entities with each other.

So in your case, on your CT product, you can add a field that references to product group and on CT application add a field that references to product group.

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