1

I have an entity reference field called 'field_client' (client) used on both the user entity and on a node content type called 'ticket'.

I'd like to build a view that only shows nodes where this entity reference field value matches the logged in user's client entity reference field value.

I'm struggling to determine how to build the contextual filter and if a relationship is required.

0

Option 1

Add a contextual filter of your entity reference field.

Then programatically get the logedin in user's entity reference field value. (I'll let you figure this part out)

Once you have this value, you can programmtically print the view like this:

print views_embed_view('view_name', 'view_machine_name', $value);

This is the machine_name

ex: print views_embed_view('hello_kitty', 'block_1', $value);

Option 2

For a non-programatic answer, View Fields View module.

1) Create a User view with a Contextual filter of User ID. Select logged in user's ID. Now add the entity reference field as field.

2) Create a Content view with a Contextual filter of Entity Reference.

3) Go back to your User View, hide the entity reference field and add View as field. Select the View in #2 and for contextual filter, use the replacement pattern of the entity reference field.

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.