Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to create lists of groups using Views. It's simple enough to make a list with gid:s but I'm struggling to display their actual names (titles).
I'm using the relationship User: Group membership to get the groups a user is a member of and the field Group membership: Group gid (Group gid) but can't figure out how to get the name from the gid.
Comments
Comment #2
ctrlADelYou are close, you just need to add one more relationship. Group membership -> Group membership: Group gid. That loads the group from the group membership and makes fields on the group available.
Since you are trying to display groups though I would create a view like this. This one is displaying groups and uses a relationship to group memberships and a uid as a contextual filter to display only groups the uid is a member of.
Comment #3
kristiaanvandeneyndeAs ctrlADel has said above: If you want a view of groups, I suggest you create such a view and then you can easily add the groups' fields to the view. If you want a view which lists more than just groups, I suggest you try to decide which "base table" makes most sense and go from there.
For instance: If you want a list of nodes with a field saying what group they're in, start with a node view and add a "Node: Parent group" relationship to the group they belong to. If you want a list of groups with one field listing the amount of nodes in the group, start with a group view and add a relationship to "Group: node content" and work with that.
In this case, you need to create a Group view and add a relationship to the group members. Then you can add a contextual filter on the membership's uid property. Or, in case you also want to show the user's fields in the view, you could even add a 2nd relationship from the membership to the user and contextually filter on the user's uid.
Comment #4
Rustan CreditAttribution: Rustan commentedSeems solved. Added to howtos.
Comment #5
kristiaanvandeneyndeAdding fix credit.