How can I create a view that relates two node types with shared taxonomy terms, and then display relevant content to a particular user?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
potassiumchloride's picture

I have two node types (node 1 and node 2) that share common taxonomy terms from the same vocabulary. These nodes also share one field in common. A set of users are related to node 2 content by node references.

I want to have a logged in user see the node 1 content that is relevant to them, given their relationship with multiple node 2s and the relevant taxonomy terms shared between node 1 and node 2.

Example:
taxonomy terms = region 1, region 2, region 3, etc.
shared field with limited values = value 4, value 5, value 6
node type 1 = observation (tagged with multiple regions and one shared field value)
node type 2 = job (tagged with one region and one shared field value)
user = assigned to multiple jobs (node type 2) via node reference

How can I create a view that will show a particular user all of the observations for his/her jobs?

I have been able to create a view (using taxonomy terms, rather than nodes) with two arguments, and this will allow me to show all of the relevant observations (node type 1) for a particular taxonomy term and one field value. Essentially, this is the content relevant to Node 2. But I have been unable to figure out how to aggregate several of these to display for one user. This also may not be the place to start, so I am open to suggestions.

I have done a lot of research to find if this question is already answered elsewhere, but I am stuck. If I should post someplace else, please let me know. Thanks!

Comments

Just a quick comment..

scottprive's picture

For starters, be sure NOT to filter on Node Type since that will exclude what you are looking for...

1) Have you looked at Relationships within Views?
I think you can create a relationship on the common field...

2) Also, Are you trying to do this entirely within Views UI?

What I mean is, if you are exploring how to do this in Views UI, you -will- be missing out on possibilities. Views UI is not all of Views. ViewsUI helps you build common types of views, but Views exported is more powerful. After exporting to PHP code you can access more settings (like passing arguments to filters, etc)

Sorry this isn't a complete solution, but hopefully it opened up other avenues to solve it.

am familiar with

potassiumchloride's picture

am familiar with relationships but it doesn't solve the problem in this case. There is not a way that I am aware of to use a taxonomy term to create a relationship.

As I am not a true developer, I don't write PHP so I can't export and edit.

use a taxonomy term to create a relationship

scottprive's picture

am familiar with relationships but it doesn't solve the problem in this case. There is not a way that I am aware of to use a taxonomy term to create a relationship.

Check out "Content Taxonomy". You can put a field on the content type, and that field can contain Terms from a Taxonomy Vocabulary.
You can then do a NODE relationship based on this Node Content field.
The field will happen to contain a term that is in the Taxonomy vocabulary, but it's not true taxonomy it is a CCK field.

You would have to experiment some to see if you can make this work, but I use Content Taxonomy to create node relationships.

As I am not a true developer, I don't write PHP so I can't export and edit.

First of all, I believe performance will suffer on a production website if you do not export the view. For this reason alone, you should export the View.

Secondly, you overestimate what skill level is involved to Export a view.
You do not need to be a programmer at all to export a view, and you will discover this if you actually investigate this issue.
You just need to follow instructions, and make sure you do not ruin the copy/paste of the "tags" that Views exports.
It is not much different or difficult than changing a template.

I'm not sure if this is

freeform.steph's picture

I'm not sure if this is exactly what you're looking for, but it sounds like you would like to embed one view within another to show multiple sets of relevant content - please see this post as it may be useful to your situation:

http://groups.drupal.org/node/92494

good things to mull

potassiumchloride's picture

I'll mull and test some more.

solved by...

potassiumchloride's picture

Using rules to assign the pending node type 1 content to the correct user and then views to allow user to see a list of pending content that has been assigned.

"You can then do a NODE

nickBumgarner's picture

"You can then do a NODE relationship based on this Node Content field."

This is what saved me. Here's my situation and what I did, just in case anybody else stumbles across this.

For some reason, this view block gave me some trouble. Just wanted to document this somewhere so I can reference this later.

This is the situation. Content Type A and Content Type B both utilize Tags. When viewing Node Type A, you want to show a block of Node Type B's content which share the same Tags as the current node.

Add contextual filter Content: Has taxonomy term ID.
1. Provide Default Value:
2. Taxonomy term ID from URL
3. Load default filter from node page, that's good for related taxonomy blocks
4. Limit terms by vocabulary (and choose your vocabs)
5. Choose "Filter to items that share any terms"

Add relationship:

Content: Tags (field_tags)
Do not require 

Thank you for your service.

tomsegarra's picture

Thank you for your service.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: