Add views contextual filter to get group ID from either URL or group content

Created on 10 February 2020, over 4 years ago
Updated 10 July 2023, 12 months ago

Currently, group module provides a "Group ID from URL" contextual filter which works properly on /group/gid* pages, including "Add new content" page (/group/gid/content/create/group_node:page for Basic Page content type for example). However, when editing/translating an existing node that belongs to a group, group ID does not exist in the URL and as a result, the contextual filter above cannot get the ID.

I know that on group content pages (nodes or users) we can use relations and the contextual filter above to filter by group ID. However, I have a use case where I need to get group ID on both the group page itself and pages if its content:

I have a vocabulary with a group reference field, so that its terms can be related to groups. Also, there is a taxonomy term field in my content type, referencing terms in that vocabulary. The content type is installed in my group type, so it can be added to my groups as content. The reference field is required to provide only those terms that are associated to the current group. To do so, I created a custom view used in my content type's term reference field with "Views: Filter by an entity reference view" reference method. The view uses relations and "Group ID from URL" contextual filter. It works perfectly when creating a node in groups. But, as explained in the first paragraph above, when I try to edit/translate those nodes after being created as a group's content, the contextual filter above cannot get the group ID because group ID does not exist in the URL anymore (/node/nid/edit, /node/nid/translations/add/en/fr, etc.)

✨ Feature request
Status

Fixed

Version

1.2

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada druplr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024