I wish to show relevant staff members when users a viewing a particular page. For example when certain pages about membership are being viewed i wish to show the staff members designated as a 'Member Relations Officer'. I have a taxonomy called 'selected job roles', in which 'Member Relations Officer' is a taxonomy term. At the moment I have set up the staff members as users on the site, therefore they are not a distinct content type. I have added a 'selected job roles' term reference to the user fields within Account Settings.

I also added the 'selected job roles' term reference to the basic page content type. I have created a view block called 'selected job roles' in which I am trying (and failing) to set up a contextual filter correctly to show the staff members. I have a basic page with 'selected job roles' set as 'Member Relations Officer' and also a user with 'selected job roles' set as 'Member Relations Officer'. I have been trying to get it to work by doing things like setting up the contextual filter get the 'taxonomy term from url' when the 'Filter Value is not available'. However none of the contextual filter settings i have tried work.

Could somebody please advise me what settings i should using in the contextual filter? Was setting up the staff as users a mistake that is stopping this from working properly? Thank you in advance.


I have now got this to work! While I don't fully understand what is going on I thought I'd share it here in case it helps somebody else.

I created a content type 'staff profile' to work with rather than using users. The staff profile content type has the field 'selected job roles' added to it.

In views I made a new view with a display of block. I added a new contextual filter for 'Content: Nid' and set 'when filter is not available' to 'provide default value' and selected the 'content ID from URL' for the type.

Then I added three relationships.

The first was 'Content: Taxonomy terms on node', selecting my vocabulary 'Selected Job Roles' and ticked the 'require this relationship' checkbox.

The second relationship I added was '(term) Taxonomy term: Content using Selected Job Roles' and ticked the 'require this relationship' checkbox.

The third and final relationship I added was the field itself '(field_selected_job_roles) Field: Selected Job Roles'.

I then added a filter criteria 'Content: Type (=Staff Member Profile)' so that only staff member profiles would be displayed.

Now, having done all of this i clicked on the contextual filter for 'Content: Nid' that I set up earlier. I think that because of the relationships that were added there is now an extra option here that was not there before. This new option is a Relationship drop down. I changed this from 'do not use a relationship' to 'field_selected_job_roles'.

The 'auto preview' at the bottom of the page did not return any results when I added an appropriate contextual filter. However going to my test page everything was working correctly!

I would appreciate it if anyone can provide an explanation on why this works. However in the mean time I am just happy to have resolved the issue.

| improve this answer | |

First you have to do this step by step.

You limit your view to the page being viewed. Set up a view of content and a contextual filter on Content:Nid to Provide default value:Content ID from URL.

Then relate the view to the Taxomony terms. Create a relationship on Taxonomy Term:field_job_roles and make it required.

Now relate the terms to the users. Create a second relationship on Taxonomy term: User using Job Roles. Set it to use the *term from field_job_roles* relationship and make it required.

This type of query tends to produce duplicates, to under Other > Query settings select Distinct.

Now select the fields you want to display. Remove the default Content: Title and add the field User: Name.

When this view is displayed on the page it will display a list of users with the Job Roles corresponding to those of the page.

| improve this answer | |
  • Thanks Triskelion. Unfortunately I am getting stuck at the step: "Then relate the view to the Taxomony terms..." I cannot find Taxonomy Term:field_job_roles When I go to add relationship and search for 'tax' the options i have are: 1. Content: Taxonomy terms on node 2. Content: Adviser Name for Taxonomy 3.Field: Staff Member Name for Taxonomy 4. User: Staff Member Name for Taxonomy. I have been trying by selecting 'Content: Taxonomy terms on node' and selected it and then choose 'Selected Job Roles', identifier 'term', but this returns the fields for the page currently being viewed. – Paul Trotter Jun 1 '13 at 12:53
  • If you have added the job_roles (or whatever name you use) term reference field to the content type, when you go to add the relationship, there should be a filter item on the list called 'Taxonomy term'. Filter the list and you should find it. – Triskelion Jun 1 '13 at 15:13

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.