Score:0

How do I grab a field from a referenced item in views?

br flag

I currently have a view block called Offerings that shows up on all my Course content-type pages that display all the offerings for the said course. These offerings are their own content type called Course Offerings. The Course Offerings content type has a field_course_reference field so to know which Course the offering is for. In order for it to show the proper courses on my view, I have a Contextual Filter set up that references the field_course_reference and have it set to "Provide default value" of type "Content ID from URL". My Course content-type also has an Entity Reference taxonomy field called field_course_category.

What I'm trying to do from the Offerings view is grab the field_course_category that lives in the Course content-type in which the view is being displayed on. I've tried adding every type of relationship and played around with a bunch of settings but no matter what I choose, the field I create remains empty and doesn't seem to grab the taxonomy term that I'm looking for.

Does anyone have any idea on how to go about doing that?


I'll try to draw the structure out a bit below as well to hopefully clear up any misunderstandings.

Content Types:

  • Course
    • field_course_category
  • Course Offerings
    • field_course_reference

View Block:

  • Offerings
    • This view lists all the "Course Offerings" content types on the "Course" pages using the field_course_reference contextual filter using "Content ID from URL".
    • Trying to also get the value of field_course_category on this view so that I can use some conditional logic.

Let me know if anything else is needed to clarify. Again, any help would be much appreciated.

Score:1
br flag

Well, I ended up figuring this out myself after digging deeper into relationships so I'm just going to post what I did in case anyone else ever comes into a similar situation.

I had to create 3 new relationships in this order:

  1. field_course_reference:content - This appeared in my "Course Offerings" content type
  2. Taxonomy term referenced from field_course_category - This appeared in my "Course" content type. I had to use #1 above as a relationship.
  3. Content using field_course_category - Relate each content with a field_course_category set to the taxonomy term. This had to use #2 above as a relationship.

Then, I went over to my fields and selected the Category of "Taxonomy term" and chose Name. I selected the relationship of field_course_category: Taxonomy term and the data that I needed was now displayed properly.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.