6

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.

5 Answers 5

3

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.
1

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.

0

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

0

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.

0

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.

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.