Hello everyone,

Using D7, I'm stuck trying to do something with Views... Basically, I want to relate content nodes of different type with taxonomy. Here's my setup:

Taxonomy Vocabulary Exercise Type containing terms (Prevention, Breathing)
Content type Exercise: contains a multiple-value term reference to Exercise Type and a few other fields
Content type Evaluation: contains a multiple-value term reference to Exercise Type, a user reference and a few other fields

When I create an Exercise node, I give it one or more taxonomy terms indicating the exercise is suited for prevention, breathing, etc
When I create an Evaluation node, I give it a user, and one or more taxonomy terms indicating the type of exercise the user should do (Prevention, Breathing, etc)

Using Views, I wish to show the currently logged in user's exercise list in a page by looking at his/her latest evaluation.

I was thinking of starting my view by showing content of type Exercise since this is what I want to show.
Make a relationship with taxonomy terms to the Evaluation content type, sorting by submission date and fetching only one
Make an other relationship with the Evaluation user
Apply a contextual filter with the "User ID from the logged in user" using the Evaluation User relationship

Am I on the right path? I can't figure out how to make the relationship with the taxonomy terms. I've tried fiddling around with the "Content: Taxonomy terms on node" relationship as well as "Content: Exercise Type (field_exercise_type)" but to no avail...

Also how can I get only the latest evaluation in that context?

Any help would be greatly appreciated...

Comments

bohemier’s picture

I've been struggling with this for days... Any help would be greatly appreciated.

J-F Bohémier
Angelicode.com

bohemier’s picture

Can linking two different content fields through taxonomy be done at all?

J-F Bohémier
Angelicode.com

bohemier’s picture

Phew ... I'm almost there!

The trick to connect two types of content via taxonomy is to make two relationships ...

- One with Content: Type of exercise - the problem here is that my taxonomy fields have the same name in my two content types, ie: type of exercise. There are therefore two "Content: Type of exercise" in the list of relations, one for the type Exercise and one for the type Evaluation. Luckily Views tells us to what kind of content it relates in each choice. Pick the one in the same type as the content the view is using.
- One with a Taxonomy term: Content Type using type of exercise - same problem but this time Views won't tell us to what type of content it is related. We must choose the one that belongs to the content type... either by trial and error or by calling the fields differently for each content.

Now we add a third relationship for the current user by adding the field and creating a contextual filter for the current user ID.

It works but ... Views gets all evaluation nodes instead of the most recent one for that user, so we get exercise duplicates when multiple evaluations use the same taxonomy terms.

How can I get just the latest Evaluation node in that case? It does not seem to make any difference whether I start the view with the Exercise or Evaluation content type. Will I have to make a contextual filter on the Evaluation node's creation date? It should be just as easy as adding an SQL LIMIT clause, shouldn't it?

TIA

J-F Bohémier
Angelicode.com

fcog’s picture

Thank you for posting your answer for your own problem, I had the same problem as you and this post helped me to solve it! Thank you!