I'm using drupal 7 and working on a site that displays nodes based on a user's taxonomy option. A quick example, i want users to make a blog entry and select a taxonomy option "Target audience". The target audience contains selected "Interests" of logged in users. Both "target audience" attached to node and "Interest" attached to user profile are from the same taxonomy vocabulary, so that when a user selects a target audience, he matches a user interest.

Is it possible to build a single view of all blog enteries and then display parts of the view based on certain conditions like "if blog entry is tagged with taxonomy value which is equal to the interest of logged in user, then display blog enteries which match the logged in user's interest.

Another use case is this: taxonomy value location = New York. Blogger makes a post and selects target audience = New York. User logs in with selected location = New York (mandatory during registration), view checks if target audience = user location, then displays only posts tagged with "New York". Another user logs in with location = Washington, but there are no posts with tag = Washington, views empty field is then displayed or default display is used (when all conditions fail).

I'm also using panels. currently with panels, to achieve this, i have to build a separate view for each user with selected taxonomy option. This makes it cumbersome because, for instance, to display for all users logged in from 52 cities, you have to create 52 views. My intention is to build a single view that decides what to display based on the checked conditions.

Help is greatly appreciated. Thanks

1 Answer 1


First, your view needs to be set up with a display of type "Content Pane". For this to be possible you need to enable the Views Content Panes module which is part of Ctools.

Next, you need to add a contextual filter (also called an argument) for your taxonomy field. The option to do this is under Advanced on the Views UI for the view. The process is similar to adding other parameters to a view, so I'll not cover it in detail.

Once the contextual filter has been added you need to ensure it can be supplied by the panel you are going to add it to. To do that, click on the Edit link next to "Argument input" under Pane settings. Set the source of the argument to be "from context" and the required context to be "term ID of first term".

On the panel editor, you need to add a context for the logged in user. On the contexts tab for the panel, select "user" for the type of context to be added, then press the add context button. Choose suitable identifiers for the user context and select the "logged in user" option, then hit Finish.

Now from the same tab, under Relationships, you should be able to find an option to add a taxonomy context via the user context. It'll be labelled something like "Taxonomy term from User (on User: fieldname [field_fieldname])". Add it and assign it a meaningful identifier.

Now finally you should be able to add your view display pane to the panel. On the content tab, you'll find it under "View Panes" on the add content dialogue. After you click on it you should see the settings for it, which should consist of a selector linking the contextual filter from the view to the context from the panel. If there is only one taxonomy term context available, the correct value will probably be already correctly set. Save everything and test.

Good luck!

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.