November 17, 2021
Anyone who has read this blog before knows that I love the Drupal Group module. It has a companion module, Entity Group Field (not yet stable), which makes it even more useful. This adds a field to entities which allows you to add them to groups on their edit form, rather than having to go separately to the group to add them.
Here's how to print the rendered value of that field in node.html.twig…
Continue reading Print entity group field value in node.html.twig and configure display modes
January 25, 2021
I guess I'm a little obsessed with the Group module, or maybe it's just that I've been using it a lot lately, and still learning its ins and outs.
One of the main purposes of Group is to control user access to various content types, based on what Group(s) the viewing user and content are in. Each Group type has an extensive permissions table where you can control permissions for anonymous users,…
Continue reading How to control access to content using the Group module - Drupal 8 & 9
January 21, 2021
Previously, I posted about how to create a view on a user's profile of content authored by that user, limited to content in Group(s) the viewing user is a member of. That tutorial shows how to accomplish that with a view of content (Drupal nodes) which are in Groups.
The person who requested that tutorial later told me they needed a view of Group content. Group content is the relationship between…
Continue reading Show group content on author's user profile, limited by viewing user's Group membership - Drupal 8 & 9
January 20, 2021
The following preprocess function will give you unique classes on the body tag for each Group content type (from the Group module). It adds two classes, one that includes the Group type that the content is in as well as the Group content type (e.g. group-content--client-group--node-page); and one with just the Group content type (e.g. group-content--node-page).
Place this code in your theme's .…
Continue reading Add body classes per group content type - Drupal 8 & 9
October 24, 2020
See also how to do this with a view of Group content
Someone contacted me asking for help with the following:
I am trying to look at the particular user profile, and below that profile contains a stream of content nodes which I will be able to see only content created by that particular user in group that I am a member of.
Example. If A is a user who created 2 Group’s and has added me to one of…
Continue reading Show content on author's user profile, limited by viewing user's Group membership - Drupal 8 & 9
June 1, 2020
I previously wrote about how to create a View of content from a Group that a user is a member of. For another site, I have to show a list of other members in the same group on user profiles. Another common use case might be showing a logged-in user a list of other members in his/her group(s).
You can do this two ways:
Create a View of Group Content of type [Group name]: Group membership
or…
Continue reading Create a View of other members of a Group - Drupal 8
May 19, 2020
Drupal has gotten so much more powerful and easy to work with, but there are still a few things that are missing that seem like they should be a given. Such as, the ability to format certain Views exposed filters, like node titles or Group names, as dropdown select lists rather than an empty textfield that requires the user to know what the possible options might be instead of presenting them.…
Continue reading Group names as Views exposed filter select list - Drupal 8
January 14, 2020
The Group module is a powerful one I turn to often when a site has a requirement for groups of users who should have specific permissions, access to edit or view specific content, etc.
A common requirement is to show a list of content belonging to the Group(s) a user is member of, using Views. That isn't as straightforward as it seems. I recently had to do this and struggled a bit, so thought…
Continue reading Create a View of content from Groups a user is member of - Drupal 8