1

Im am trying to create a view that pulls in content that matches to the user. This is done with two taxonomy fields that are added to the user profile and the content type. These are job role and speciality. I know how to set up the view to pull in content using just 1 of these fields but how can I get it so its an AND condition. I need to pull in content that has both the same job role and same speciality as the user. Is there anyway of achieving this through the views UI or do I need to alter the query?

Thanks

3 Answers 3

0

With Drupal 7 and Views 3 you can match on multiple taxonomy terms using contextual filters. I posted about this on drupal.org here. Maybe it can be adapted to your particular situation.

1
  • Hi, thanks I've tried this but it seems to be an OR condition regardless of if i use a + or ,
    – user26183
    Commented Jun 5, 2014 at 13:51
0

I think you can achieve that using Views module as usual. In the edition of the view:

  1. Look for the Filter Criteria section
  2. Locate the button in the right.
  3. Click on the arrow and you should see the link And/OR, Rearrange.
  4. Click it and add the conditionals you need.

Hope this is what you're trying to achieve.

0

I ended up adding a relationship for Content: Taxonomy terms on node and using hook_views_query_alter() and loading the users profile and adding two where clauses like so :

$query->add_where(0,"field_data_field_job_role.field_job_role_tid",$job,"=");

$query->add_where(0,"field_data_field_specialty.field_specialty_tid",$specialty,"=");

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.