Entity type: Book

I have entity type called "Book". It has one field called "book_id".

Ex: science book(Book_name) -> 100(Bokk_id)
Maths -> 101
english -> 102


I have user, he has one field attached with user profile called "book_name". "Book_name" is a taxonomy reference field.

"Book_name" has one field called "book_id"

"Book_id" is free text field, it has more than one value by comma separator. Like 100,101,102.

Ex: user->book_name(taxonomy reference field)->book_id

Using views, I want to filter entity type "book" by current logged in user "book_name->book_id".

2 Answers 2


Because this is a comma separated text field, your best bet is with custom module that gives your view the ids in a 2+6+36+98 format.


In that answer, I described how to pass one value from a user field. For you, you'd need to load the taxonomy entity and work with that.

Then, to do multiple, you just need to add a bit of php to split your text field and turn it into the format above with +. You still only pass one argument and in your view, enable multiple values in the contextual filter's settings.

I can't give a longer answer until tomorrow. Btw, if that text field has node ids for books, you should use the entity reference module.


This can be done in views without creating a custom module.

Since you want to list entities that use the same term reference as the user account, its best to create a view of terms and add relationships to the user and book. For the user you need to add an extra relationship since its a level deeper to reach the term reference field.

Add the book fields that you want, using the book relationship.

Then add the term reference field two times, one with the user relationship and one with the book relationship. You may hide these fields.

Then add filter 'field comparison', selecting both similar term reference fields, and choose 'is equal to'. Also add the filter user (with relationship) is 'currently logged in user'.

The result is a view showing books that have the same term reference (book_id) value as the currently logged in user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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