2

I'm having difficulty with setting up a view in Drupal 7. I'm going to use a sports example as a way to illustrate my problem:

I have three content types: 1. Team 2. Roster 3. Player

On the ROSTER editing page, I select which TEAM this roster belongs to, via Entity Reference.

On the PLAYER editing page, I select which TEAM this player belongs to, via the SAME entity reference field.

I've created a view, specifically a block, that lists the players on the roster page. However, right now, it's displaying ALL players. I know this is what contextual filters/relationships are for.

However, I get lost in the contextual filter and relationship settings. I've read a lot of documentation about each, impressed by all the different explanations and demos, but can't seem to find the right configuration that works for my problem.

I'm trying to filter the players on the ROSTER page, based on the TEAM that is selected both in the ROSTER and PLAYER content types.

Any help, suggestions, advice is appreciated. Thank you.

0

a roster lists the players on 1 team, correct? If the view is at a url like roster/TEAMNAME you want a listing of players where the contextual filter on teamname provided by argument 1 in the URL, or else 404 or hide the view.

If the roster is not on a URL but say a block on 1 players page (showing the rest of the player roster for his team) then I would add a Views Field View to the player content type that uses the player's own team as the argument to the View I describe above.

Contextual filters are good when you provide the context for the view (like a URL, or another field). relationships just help you to get more information into your view (like additional fields).

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.