Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I was wondering if one can link up the data with views in this way:

I have two content types (current_state & desired_state), both have 3 fields (location, item, quantity)

How can I join the data, so that it displays in a table like:

location | item | desired_quantity | current_quantity

I separated those content types because people with other permissions are allowed to edit them.

share|improve this question
add comment

5 Answers

Suppose we have 2 content types A and B and want to display the content of content type B which have a field reference ie both A and B both have a common field. then:

  1. We simply add B to the Filter Criteria of the view.
  2. Add an nid of A using Contextual Filter in the advance Options.
  3. Add a relationship of B in reverse order in the relationship field in advance options.
share|improve this answer
add comment

Follow these steps:

  1. Install the module refernces

  2. Create a new view.

  3. In the filter criteria section add the second content type which you want to get displayed.

  4. Then in contextual filter section,add the field node reference with which you have linked the second content type.

  5. Lastly, add a relationship of second content type in reverse order to get the output.

share|improve this answer
add comment

You can make use of relationship in views tutorial i found here

share|improve this answer
add comment

One way to do this would be to use the References module to create a relationship between the two nodes:

  1. After installing References, add a node reference to one of the content types that you can use to point to the other one.
  2. When creating the View, add a Relationship to the Referenced node.
  3. You will then be able to see fields from the Referenced nodes when you go to add a Field to the View.

So if, for example, you added a node reference field on the current_quantity field to reference nodes of type desired_quantity, you can then add a Relationship to related desired_quantity nodes, then add a desired_quantity field to your View of current_quantity fields.

share|improve this answer
add comment

If you want to just display those two content types in the table (views) you don't need to relation between the content typs.

Just follow this steps:
1- Create new view (table display) .
2- Filter : content type (current_state & desired_state).
3- Add your fields.
4- In format section click on settings beside "table".
5- You can display two field (each one from different content type) by selecting the field in "COLUMN" . For example i have two fields (Car model,motor model) so from "COLUMN" of (motor model) select (car model) and they will display in one column.

6- Rename the first field (here in my example will rename the "Car model" field to "model").

Repeat step 5 and 6 for all fields you have in tour views.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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