2

Aim

I am working on a Drupal 8 site that has articles which have a 'interests' field, and each User profile has a 'interests' field.

I want to create a view that only shows articles that the currently logged in user is interested in. For example, if the currently logged in user is interested in "Sports" and "Business", the view should show all articles that are tagged as either "Sports" or "Business".

Attempts

I presume that the solution will involve using Relationships and Contextful Filters. I have read about both here and here.

I have checked previous answers, and think this one is pretty close to what I'm trying to do: Display content having the taxonomy of the logged in user

However, I couldn't seem to get it to work for Drupal 8

Amends

Include of screenshot enter image description here

2

1) Create users View

enter image description here

2) Add contextual filter of User ID

enter image description here

3) a) Add relationship of reference field

enter image description here

3) b) Checkmark require this relationship

enter image description here

4) a) Add relationship of Content with term

enter image description here

4) b) Checkmark require this relationship

enter image description here

5) Now in FIELDS it should allow you to add title field

enter image description here

6) Remove Name from fields.

7) Add FILTER CRITERIA of Published content

enter image description here

enter image description here

Overall, should look like this:

enter image description here

enter image description here

6
  • Thank you @No Sssweat So the thread below won't solve the problem without custom code?drupal.org/forum/support/post-installation/2011-03-31/…
    – Darcy
    Sep 25 '20 at 5:36
  • @Darcy I take that back, added a solution based on that link.
    – No Sssweat
    Sep 25 '20 at 6:04
  • thank you for that! Unfortunately, I'm not getting any results populating on on the view page (even though articles nodes are generated with the relevant tags are generated). Coud it be because the user profile is using field_interests and the article is using field_event_category? Should I be using 'Add relationships: 'Content using field_event_category' instead?
    – Darcy
    Sep 25 '20 at 6:58
  • @Darcy nope needs to be using field interest relationship. Can you provide a screenshot of your View's settings? Maybe you did something wrong.
    – No Sssweat
    Sep 25 '20 at 7:40
  • I have included a screenshot in the original question for your reference! :)
    – Darcy
    Sep 25 '20 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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