1

In Drupal 7, what are the best ways of creating relations between nodes?

Say I have a number of articles about famous writers. I want to build an alphabetical list of them using Views. As writers often have pseudonyms, I want these pseudonyms to appear in the list too but creating a node for a pseudonym that is identical to its respective Writer node in all aspects except title sounds like not quite good idea.

I thought a bit and came up with 2 node types, Writer and Writer_Pseudonym:

  • Writer

    • Title
    • Body
    • All other fields
  • Writer_Pseudonym

    • Title
    • Target Node Id

Now I want to build a view in which nodes of type Writer_Pseudonym will display body text of their target nodes:

Title: Doe, John (Writer)

Body: John Doe, also known as Evil John, is a writer that became famous after creating an autobiographical novel "Foobar".

Title: Evil John (Writer_Pseudonym)

Body: John Doe, also known as Evil John, is a writer that became famous after creating an autobiographical novel "Foobar".

Is it possible to do it with Views? And if not, are there any other ways to establish relations between nodes while being able to use fields of target nodes?

2
  • How well does this example relate to your actual use case? Because the best relationship solution depends on the size, complexity, and frequency of said types and relations.
    – Merrick
    May 10, 2012 at 22:13
  • @Merrick I'd say this example relates to the actual use case quite well. I need these "pseudonyms" for only one node type, they are not very frequent (probably one in 7-10 nodes needs a "pseudonym") and "pseudonym" needs to load no more than a couple of fields from its target node.
    – Ari Linn
    May 10, 2012 at 22:21

1 Answer 1

0

Your best bet for this kind relationship is going to be Taxonomy. You can create a free tagging vocabulary (exactly like the vocab that is initialized with the Article content type in a standard profile D7 install) and as these "Authors" come up with a need for a "Pseudonym" you just tag that node with it's term.

Views supports most every use case (if not all) you can imagine working with Taxonomy.

Because Taxonomy is core it's further developed and easier to use than alternative relationships (references, hierarchy, etc).

For the above example, you'd could configure the view to display all (full, teaser) or part (fields) of the "Author" content type based on being tagged with the relative "Pseudonym". Views are a little daunting at first but if you keep playing with them, you'll soon realize their immense capability.

Just comment if you need clarification on any of the above...

Your Answer

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

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